Archived

This topic is now archived and is closed to further replies.

CoolTomK

Memory Allocation Problem!!

Recommended Posts

CoolTomK    122
Allright...this problem is driving me crazy! I''m using Paul Nettle''s memory manager to check for leaks, but it''s giving me a hard time. There are three pointers to memory I just cant deallocate. Whenever I try to delete[] these pointers to arrays, I hit an assert error saying "If you hit this assert, you tried to deallocate RAM that wasn''t allocated by this memory manager.". The allocation code(using new[]) for these pointers is in the same file as the deallocation code(using delete[]), which includes the "mmgr.h" file, so I''m pretty sure that the memory manager allocated the memory. Does anybody familiar with this memory manager know how I can fix this?

Share this post


Link to post
Share on other sites
CoolTomK    122
Nevermind...figured it out- I was using ZeroMemory to clear out the arrays, I guess ZeroMemory() was reallocating my memory without the memory manager.

Share this post


Link to post
Share on other sites
Kylotan    9850
ZeroMemory doesn't reallocate anything, it just calls memset to change the values of the bytes at the address you give it.

It might be that you're zeroing out the magic number that the memory manager might use to determine whether it allocated the memory or not. In which case, you're still trashing memory you shouldn't really be touching.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files ]

[edited by - Kylotan on May 5, 2002 10:04:07 PM]

Share this post


Link to post
Share on other sites