my_array = new my_strucuture[100]; // creates 100 element array
delete [] my_array; // deletes the whole array and not just the first one
If you use the regular delete, this will cause some very nasty and hard to trace memory leaks.
Steve
Thomas Ward wrote:
Hi All,I have an application, with the following declarations:
typedef struct {
... // a couple fields
} my_structure;my_structure my_array[100]; // global variable
This worked fine, but I realized that I only need this array for a specific
function. So, to minimize global memory used, I changed it to:my_structure *my_array; // global variable
which I then allocate and free. This works fine, as well. The thing that has
me perplexed is that the size of my .PRC file is exactly the same either
way! I THOUGHT the size of my .PRC would shrink by approximately
100*sizeof(my_structure), but it didn't shrink at all! So, two questions:1. Why is my .PRC file the same size either way?
2. Am I wasting my time? Or is this type of memory saving worth doing?Thanks in advance,
Tom Ward
