Subj : Re: malloc() To : borland.public.cpp.borlandcpp From : Bob Gonder Date : Thu Jun 24 2004 11:03 am Jan Vernimmen wrote: >I am indeed targeting Windows. >I can try your suggestions, but did you read the answer given by Ed Mulroy? Of course. I always read Ed's suggestions. I've learned a lot from them. I don't remember what his suggestion was, though. I just figured if you were going to change from malloc() to new() and, as was pointed out, that wouldn't buy you much, then moving to the Win API might be a better path than new(). I don't think Windows has (as many) fragmentation problems. It would also help you to decide if the problem was with malloc or your code. Of course these won't fix your problem is in how you use the allocated memory. As a side note, if I remember right, you freed in the same order you malloced. I figure that makes the job of the memory manager more difficult. So I _always_ free in last-in-first-out order. It also makes the program very symetric. You might think of each malloc as a new bracket: a=malloc() if( a ) { b=malloc() if( b ) { do stuff free(b) b=NULL } free(a) a=NULL } .