feathj
feathj

Reputation: 3069

Dump process memory to disk to analyze for memory leaks

I have a 32 bit msvc++ application running in a production environment that is leaking memory. It basically will run for a few hours until it consumes all 3 gb of addressable memory and terminates.

I was thinking that if there was a way to suspend a process and dump it's memory to disk, I could analyze the memory to see if there are any patterns to what it leaking.

Not sure if this is even possible. I'm just throwing science at the wall and seeing what sticks.

Some input would be much appreciated.

Upvotes: 0

Views: 1609

Answers (2)

user208608
user208608

Reputation:

For the really quick way, Purify or DevPartner Studio will usually point you right to the leak and show you a trace from where it was allocated to where it was leaked. It also will expose quite a few other errors too.

Using the CRT built in tools is fine if you have the time to do it. These tools cost money, so I suppose you weigh the cost of time it is going to take to track them down with CRT memory dumps with the cost of a license.

When doing Windows dev, this has helped get to the bottom of many leaks quickly. I prefer DevPartner over Purify, but probably because I've only used Purify under Linux and found the way it worked too cumbersome.

Upvotes: 0

ildjarn
ildjarn

Reputation: 62995

This is extremely straightforward as long as you're confident that you have some means of finding something useful by analyzing the process' heap. The tools involved are all free and instructions are here: Dump Files

That said, if you could just run a debug build for a while, the CRT will do all the work for you. See Finding Memory Leaks Using the CRT Library

Upvotes: 2

Related Questions