My program eventually consumes all ram and crashes... looking through the code, I can't find anything that stands out that would do this.
Asked
Active
Viewed 418 times
2
-
this is a Q&A site. You can thank in the comments to answers, but it's frowned upon to do that inside your question. – 0xC0000022L May 16 '12 at 20:04
-
1You could try a [memory profiler](http://www.bing.com/search?setmkt=en-US&q=memory+profiler). – jrummell May 16 '12 at 20:05
-
There is not enough information here to answer your question. What does your program do? Is it a server process, serving clients? How often does it do things? What memory *do* you allocate? When do you free that memory? What else have you tried, other than looking? – Greg Hewgill May 16 '12 at 20:06
-
@Greg: I think the question is still valid, albeit a somewhat broad and fundamental question. Especially since VS6 is ancient by now and modern tools/methods may not apply to it. – 0xC0000022L May 16 '12 at 20:07
3 Answers
1
Could you modify the code to use the debug version of malloc
and free
? If yes, check _malloc_dbg and _free_dbg.
(You could write own new
and delete
operators based on these functions.)
As I remember VS 6.0 has no _realloc_dbg
.
#ifdef _DEBUG
#define _CRTDBG_MAP_ALLOC 1
#include <Crtdbg.h>
#define malloc(size) _malloc_dbg(size,_CLIENT_BLOCK,__FILE__,__LINE__)
#define free(addr) _free_dbg(addr,_CLIENT_BLOCK)
#endif

Naszta
- 7,560
- 2
- 33
- 49
1
You can try BoundsChecker (now DevPartner): http://www.microfocus.com/products/micro-focus-developer/devpartner/index.aspx
You will be able to see memory leaks, interface leaks and other problems in your code.

Sergey Sirotkin
- 1,668
- 11
- 7
1
Depending on the type of leak you can use umdh, or debugdiag as simple tools, otherwise I would recommend windbg. All of these are free and are part of debugging tools for windows, you can Google for tutorials on all these tools. The command for automatic leak finding in windbg is !heap -l.

EdChum
- 376,765
- 198
- 813
- 562