Why can't I delete this array?!

Started by
11 comments, last by CodaKiller 15 years, 4 months ago
Quote:Original post by Evil Steve
Quote:Original post by CodaKiller
So how should I be checking this? Also I know for a fact that it is creating a memory leak. As I said earlier I fixed it and the reason is quite simple, I needed to Delete the DC and not release control of it.
Well, yes it's a memory leak, but Task Manager isn't suitable for checking for memory leaks.

You can check for handle leaks by using the GDI Objects column in Task Manager, and for memory leaks from your code by using a memory leak checker like mmgr or similar.

If you allocate 500MB of memory and then release it, the OS might realise that you've requested a lot of memory recently and decide to keep it handy for your app. In that case, your application would still show over 500MB used for it's working set, even though there's no actual leak. Similarly, Vista has Superfetch which will slowly allocate memory, even when it's doing nothing (Since otherwise that memory isn't being used) - I've seen people complain that Vista leaks memory because they look at task manager and see the memory usage going up and up.

EDIT: Link to my memory manager: MemMgr.h and MemMgr.cpp. Just drop those files into your project, do a full rebuild, and you'll get a report at shutdown time of any memory leaks.


I added it to my project and defined USE_MMGR, is that all I need to do?
Remember Codeka is my alternate account, just remember that!
Advertisement
Quote:Original post by CodaKiller
I added it to my project and defined USE_MMGR, is that all I need to do?
And rebuild, yes. The USE_MMGR define is automatically defined for debug builds.

Note that this only tracks allocations from new or new[] - although malloc / realloc shouldn't really be used in C++ anyway.
Quote:Original post by Evil Steve
Quote:Original post by CodaKiller
I added it to my project and defined USE_MMGR, is that all I need to do?
And rebuild, yes. The USE_MMGR define is automatically defined for debug builds.

Note that this only tracks allocations from new or new[] - although malloc / realloc shouldn't really be used in C++ anyway.


Wow that's very useful! Thanks!
Remember Codeka is my alternate account, just remember that!

This topic is closed to new replies.

Advertisement