Sign in to follow this  
  • entries
    557
  • comments
    1237
  • views
    422070

Untitled

Sign in to follow this  

94 views

Memory managers for everyone!

MemMgr.h and MemMgr.cpp

Example usage:

int main(int, char**)
{
int* n = new int[42];
return 0;
}



That'll give you debug spew at application shutdown, and write to memleaks.log, then debug break. The debug spew is the same as you get in memleaks.log, and is:

1 active allocations totalling 168 bytes:
+ ID 00000002, tag ID 0x00000000: 0x00356B84 168 bytes [main.cpp:9 (main)]
End of allocations




The code only works on Windows, and should work fine on x64. It's ported from my engine code, but I've just changed a few things (Like the assert doesn't use my engine's assert(), and the _WIN64 define is actually BUILD_X64 in my engine).
It'll also only work on Visual Studio, due to my #pragma black magic. Only tested on VC2005 so far.

Any questions, give me a shout. I'm going to post this in General Programming now. EDIT: Done.
Sign in to follow this  


2 Comments


Recommended Comments

Does this also work with STL?

I remember using MMGR by Paul Nettle. (http://www.paulnettle.com/)
And that couldn't be used with STL.

[EDIT] Never mind... Should have read the post first. ^_^'

Share this comment


Link to comment
Yup, it does. I've used MMGR before, and I got really annoyed having to piss around with the order of includes to make sure MMGR wasn't included before STL headers [smile]

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now