开发者

Do you know a tool for c++ program that shows which program line allocated how much heap?

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).


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


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

What's your favorite profiling tool (for C++)

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


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜