Sign in to follow this  

Memory Tracker

This topic is 3574 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hiya, I've been playing with Evil Steve's memory tracker (here, thanks Steve) and it seems really good. In parts of my code, memory is dynamically allocated in a DLL, and then released in an executable. I've been having some trouble tracking this correctly because an instance of the memory manager (singleton) is created in each module (EXE, DLL). I've not really used singletons before - is there a way of sharing them between applications and DLLs? Thanks for any help [smile]

Share this post


Link to post
Share on other sites
Yes off course. Singleton is as any other object, located somewhere in memory, just pass to dll, exe memory location of it, and you will know where to find it.
Singleton is only one static object declared in class, which is ensuring you are not creating two or more instances of given class. So if you have singleton class, and you want to use it in two or more application, create it in one app as pointer and pass pointer memory address to other one, in which you set its pointer to passed pointer.
Example:
CMemMngr *manager;
...
//app entry point
manager = new CMemMngr();

// on later point when you loaded dll
pApp->SendMsg(MEM_MNGR_ADDRESS, &manager);


// and in other executable when you catch the message
manager = sent_address_of_manager; // <- which is pointer from first app

Never tried this but it should work.

Share this post


Link to post
Share on other sites

This topic is 3574 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

Sign in to follow this