Xref: news2.mv.net comp.os.msdos.djgpp:807 From: beale AT leland DOT Stanford DOT EDU (John Beale) Newsgroups: comp.os.msdos.djgpp Subject: malloc/free ends up fragmenting dynamic memory? Date: 5 Feb 1996 13:26:32 -0800 Organization: Stanford University, CA 94305, USA Lines: 21 Message-ID: <4f5sm8$2kt@cardinal1.Stanford.EDU> NNTP-Posting-Host: cardinal1.stanford.edu To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp I don't know if this problem is specific to DJGPP or generic to gcc or all C compilers, can anyone advise? I'm using DJGPP v2.0 beta 4 under DOS 5 with cwsdpmi.exe. I observe that my program, which dynamically allocates and frees (malloc() and free()) many large and different-sized arrays, eventually ends up not being able to malloc even a mid-sized array when it used to be able to malloc many of that size. Quitting the program and restarting solves the problem. I am guessing that the many malloc/free operations fragments the memory store analgous to hard disk filesystem fragmentation with many saves and deletes, such that a contiguous memory segment for a large malloc() can no longer be found. Is there a malloc_unfragment() command or equivalent? How do other people handle this problem? Thanks very much for any assistance. John Beale ------------------------- beale AT jumpjibe DOT stanford DOT edu -------------------------- http://jump.stanford.edu:8080/beale/