How do you trace a memory leak ??

Started by
4 comments, last by yanuart 21 years, 3 months ago
It seems that I''d released all my mem when exiting my app, but it still give me the memory leak warning ?? how how how ?? btw, I''m using VC++
Ride the thrill of your life
Play Motorama
Advertisement
crtdbg. Have a look on msdn for the specifics.

Neil

WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!
WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!
you could try overriding the new and delete operators. you could then have a data structure which stores each memory allocation...the line number ( by using the __LINE__ macro) in the program where it was allocated, how much was allocated, what type of allocation it was ( eg. * or [] ). then you can print out a log of all the memory allocation structures. you can then tell which new wasn''t paired with a delete and so you can track memory leaks.if you need further help, i''d be happy to help.
or you could skip reinventing the wheel and use ftp://ftp.3dmaileffects.com/pub/FluidStudios/MemoryManagers/Fluid_Studios_Memory_Manager.zip

hth
yes it is reinventing the wheel. but it''s a good exercise in learning how a few things regarding how memory allocation works. i think it''s better to write your own things like this, if you just keep copying code off people, how do you learn ? and you only need to do it once...

Also, if you''ve written it, you understand it a lot more than using someone elses and getting confused about certain things

the debug leak report gives you allocation number. use _CrtSetBreakAlloc to break on that allocation, and use the call stack to see which object is leaked.

This topic is closed to new replies.

Advertisement