Hello,
strange behaviour have seen with large array of objects in the following code.
If class internal array has length 100 memory is freed after delete [].
But if the length is smaller, e.g 20, memory isnt freed.
What is the reason?
There is no errors messages. Problem is memory consuming after delete [].
When length of class internal array fMasterNum is 100, memory consumption is 4.1 Gb.
And after delete [] (and before the second std::cin) memory is freed completely.
If length of class internal array fMasterNum is 20, memory consumption is 1.2 Gb.
And after delete [] (and before the second std::cin) memory is freed on 0.3 Gb only.
Thanks for the clarification. I'm not able to test the 4.1Gb version as my system doesn't have that much RAM available. With the values changed to a smaller size, I tested the program, but again, my system has insufficient ram, so virtual memory is required. What this means is there is prolonged hard drive activity as the required memory is paged to/from the hard drive. This did slow down the delete [] phase for me, but the memory was always released properly. (I used Sysinternals Process Explorer on XP to examine the performance).
Actual behaviour I presume will depend upon operating system, compiler and available physical resources.