Message-ID: <361E6945.5FCA5FAC@tecnotron.com.br> Date: Fri, 09 Oct 1998 16:51:33 -0300 From: Charles Ricardo Staub X-Mailer: Mozilla 4.05 [en] (Win95; I) MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Memory allocation Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com /* Please, excuse-me but I need answers to be sent to heckler AT mat DOT ufrgs DOT br My computer is now broken, so this is a borrowed one ;) */ Hi there! the following program allocate lots of memory and free it. Then, try to allocate again, but with a diferent block size. It dosn't work ! -> first part runs OK, but the second gets a "virtual memory exceed" error ! May be I'm a complete stupid and this code is absolutaly wrong, but also may some of you guys have a tip about it. So ? Oh, please test it (if you want, of course!) using CWSDPR0 ! ---- included test.cc ---- #include #include #include int _crt0_startup_flags = _CRT0_FLAG_LOCK_MEMORY; void main (void) { // discover the amount of free memory: _go32_dpmi_meminfo info; _go32_dpmi_get_free_memory_information(&info); unsigned long int FreeMem = info.available_memory; printf("avaliable memory = %d\n",FreeMem); // Let's reserve 10MB for safety: FreeMem -= 10*1024*1024; printf("using %d bytes\n",FreeMem); printf("starting alocation...\n\n"); int Fraction; char *ptr[100]; // Now, allocate some pieces: Fraction = 10; for (int i=0; i why don't just allocate the largest amount of memory I can in the initialization, then free it ? As the FAQ says, this memory should be allocated to the local heap of the problem, and from this point on, no call to DMPI will be made for memory requests ... Cloud: it seems for me that I need to reuse the previously allocated blocks in the same block-size I did first, otherwise I will receive a "virtual memory exceed in new" ... Ideas ? Any idea of good on-line resources for memory allocation under djgpp/dpmi ? ps.: I really don't want to "reinvent the weel", i.e., made my own memory managing.