Subj : Re: Memory Management,. C Vs C++ To : borland.public.cpp.borlandcpp From : waking@idirect.com (Wayne A. King) Date : Mon Nov 17 2003 11:19 am On 16 Nov 2003 10:59:43 -0700, "Rob C. " wrote: >In straight C - You have an array of 5000 pointers to int, >[ int *ArrayName[5000]; ], [snip] >you can free-up the 5000 nodes and recapture that much memory, >but the 5000?, 6000? bytes used by the array are still in use >and thus still inaccessible. It depends. If it is a local automatic array it will be created on the stack, and the space will be reclaimed when the array goes out of scope. If it is local static or global it will be allocated in the data segment for the duration of the program's execution. If you allocate the array of pointers itself using malloc, then it will be created on the heap and the space reclaimed when you free that allocation: int **ArrayName = malloc(5000 * sizeof(int*)); // use it if not NULL, then later ... free(ArrayName); -- Wayne A. King (ba994@torfree.net, wayne.king@ablelink.org, waking@idirect.com, Wayne_A_King@compuserve.com) .