Question

I am trying out a C/C++ program, I want to know how much memory i am using due to heap and some other data structures. So how can I find out the amount of memory used by my various data structures?

I think that malloc operator should be overridden but I am not sure about the same.
I am working on Linux and on Netbeans 7.1.

Was it helpful?

Solution

You can use memory profilers for c++ like Valgrind as recommended in similar questions. see this

For netbeans IDE look at this.

OTHER TIPS

If you want to use hand-made memory profiling then you need to overload operator new and/or malloc() function. Though malloc() can be overloaded easily, but you need to use macro tricks.

Advantage of using and overloading operator new is that, it's easier, elegant and you can evaluate each type of struct/class separately.

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