Question

In our company we have an inhouse framework similar to the mtrace (MALLOC_TRACE) functionality in glibc for detecting memory leaks. This framework is written to run on Windows, but it doesn't work very well in GNU/Linux.

So, do anybody know of a portable equivalent to mtrace (MALLOC_TRACE), that can run on Windows, GNU/Linux and hopefully even MacOSX?

Was it helpful?

Solution

Did you tried dmalloc?

http://dmalloc.com/

perhaps I think on linux valgrind is much better

OTHER TIPS

A few month ago, I developed the base for a portable C library, allowing some kind of OOP.

Memory is managed with reference counting, and the project includes a memory debugger, that keep track of all allocations, providing extended debug informations when necessary.

It's published under the BOOST license, so you're free to use it.

https://github.com/macmade/XSFoundation/

Current revision is actually in a non-workable state, but you may check older ones, to see how it's done.

A working version is available in the tags (1.2.2-0). This one builds fine on OSX, Windows and Linux.

Memory stuff is located mainly in the source/core directory:

Here's the kind of output for a SegmentationFault, for instance:

enter image description here

You can then get backtrace informations, display allocations, etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top