Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
when does delete actually free memory?
hi there i've got the following code to test on, you can try it on your computer aswell
char* array = new char;
ive placed breakpoints on all rows and steps my way through during debugmode
in taskmanager in windows i look at how much memory my application is using and after it excecuted row 2 the memoryusage increases but after it excectued row 4 the memoryusage doesnt decrease. its as if delete had no effect
however if i increase the size of the array to 1000000 the memoryusage does decrease and its as if delete is doing what its supposed to.
i can imagine that therse some sort windows memory usage optimization algorithm lying in the background causing this problem.
and the problem is that there's no way to test for small memory leaks if theres no change in the memoryusage reading.
my question is when does the "small" memory get deleted by the OS? this might be a hard question and possibly i posted this in the wrong category but this is a problem i have when i program in C++