开发者

C++ memory analysis

开发者 https://www.devze.com 2023-01-05 18:50 出处:网络
What 开发者_如何学JAVAare some of the good tools for analysing memory (for footprint, allocation and deallocation)? I am familiar with valgrind. If there are tools apart from that, would be nice to kn

What 开发者_如何学JAVAare some of the good tools for analysing memory (for footprint, allocation and deallocation)? I am familiar with valgrind. If there are tools apart from that, would be nice to know about them.

Best.


IBM has Rational Purify for both Windows and Linux. I haven't used it, as it's rather costly, but there is a free trial available.


If you're talking about valgrind I suppose that you are interested in Linux software.

You can easily build your custom report for footprint allocation and deallocation by using MTrace. It is not directly C++ but directly integrated into the GlibC. As far as I know C++ new and delete operators use this to allocate the memory before calling the constructor and deallocate memory after calling the destructor.


The nice thing about mcheck is that you automatically have it whenever you use glibc. Set the environment variable MALLOC_CHECK_ to 1, and diagnostic is printed on stderr every time heap inconsistency is detected; if set to 2, abort() is called immediately.

The mcheck documentation is here:
http://www.gnu.org/software/libc/manual/html_node/Heap-Consistency-Checking.html

You can also use mtrace to trace malloc in endless detail:
http://www.gnu.org/software/libc/manual/html_node/Allocation-Debugging.html

0

精彩评论

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