tags:

views:

93

answers:

4

Hi,

I have a c++ program that dies because of out of memory error.

Do you know a tool for c++ program that shows which program line allocated how much heap?
I would like to figure which part of the program consumes most of the heap.
Thanks.
Platform: Microsoft C++...Windows

By the way, can heap corruption cause excessive memory usage?
Solution: It was not heap corruption. Some uninitialised variables were used to allocated the amount of memory. I used valgrind which showed the problem immediately (both the presence of huge allocations and uninitilased variables).

+3  A: 

You could use something like valgrind on *nix platform or crtdbg checks on windows platform.

Kotti
+2  A: 

It sounds like you want a profiling tool of some sort. A quick Google search brought up this Stack Overflow question:

http://stackoverflow.com/questions/26663/whats-your-favorite-profiling-tool-for-c

(It says "c" in the URL, but the question is about C++.)

JAB
A: 

In visual studio, if you get an exception like that while debugging, the code will break at the point of the exception. Then you can navigate up the call stack to see exactly where you are in every function up to that point. I assume something similar would hold for other platforms.

Cogwheel - Matthew Orlando
This could be wrong in case of heap corruption.
Kotti
FWIW, that "by the way" was added after I answered...
Cogwheel - Matthew Orlando
A: 

Paul Nettle MMGR You find a "mmgr" there, which I have used some time ago. Its very useful IMHO.

InsertNickHere