C++ delete doesn't allways work as expected in windows -


i'm frustrated on simple (or guess), in matter appreciated. (sorry if has been answered, haven't had luck of finding somewhere else, that's why i'm asking...) so, i've written following simple program, test purposes.

class myclass{     int x[99999]; public:     myclass(){} };  int main(){     myclass *x = new myclass;     delete x; } 

having used break point in 1st line of main, it's easy me (using visual studio 2010 , windows resource monitor) realize, after delete called, reserved memory program not released after delete x. if change x[99999] in myclass, x[999999] (adding 9), allocated memory indeed freed. i'm worried peculiar behavior (which happens in various similar tests), expected, program not what's worrying me... first problem that, i'm not sure if can trust windows resource monitor or not. updating output time? or when amounts of space (de)allocated? if it's second, please recommend me tool monitors resources precisely? secondly, have used program (i don't remember called) checks executable memory leaks, larger project of mine. no memory leaks found. however, event cause small amounts of memory leak (according windows resource monitor). every 4 calls event cause 1 kb of memory leak. i'm quite that, part of code correct, example above reserves small amounts of memory, windows perhaps doesn't "consider" worthy enough deallocate when asked to, perhaps? or perhaps each function call on windows collects system garbage? (i doubt that...) or perhaps heap calls accumulate garbage? (i doubt too...) code above free memory reserves expected machine? have propose me peculiar situation? please don't start telling stack, heap, , how work. i'm aware of of that, theoretically. doesn't work in practice. thank in advance, , sorry if english not perfect (not native tongue).

you've asked lot of unrelated questions. let me try clear main issue:

the process has memory management code makes intelligent decisions when return virtual memory operating system , when keep around in case it's needed later. since virtual memory (address space) not considered scarce resource, there's no particular reason should want process release it. operating system puts physical memory (ram, stuff that's precious) best use can @ times, giving , taking processes thinks best, no matter process allocated virtual memory.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -