Heap viewer?

Hi,
I used a heap viewer to check for memory leaks. I have many of them and its hard to find out where it is not being freed. Is their a way to use the debugger to log the addresses of the data it allocated on the heap. This way I can trace it back. Or is their any other way to fix memory leaks properly.
The easiest way is to remove all occurrences of new and delete from your program. Then it is extremely difficult to create a memory leak. (Also, this is not a joke - http://www.LB-Stuff.com/pointers )
Last edited on
In my game server if I have a Player object and it is stored and pointed to with a shared_ptr in the player handler. Then that player is passed to an Npc object as a shared_ptr. Then it is stored in the Npc object as the current player the npc is attacking. What would happen if the playerHandler removed the player. Their is still an instance in the npc object. I could use weak_ptrs I suppose but if I didn't use them wouldn't it clog the memory This is just an example by the way. Would one shared_ptr and a bunch of weak_ptrs be acceptable in this instance? or is their a better way.
Last edited on
A single shared pointer and many weak pointers is a good approach when the lifetimes of objects are unrelated to each other.
Ok cheers
Topic archived. No new replies allowed.