1

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.

2
  • also see this question Commented Jul 1, 2012 at 12:37
  • @hamed Thanks..+1 to ur comment. Also since I am working on netbeans...is there anyway by which netbeans may help me with...i am a complete novice at this..thats why asking..also thanks helping. This community really rocks because of people like u. Commented Jul 1, 2012 at 12:41

2 Answers 2

1

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

For netbeans IDE look at this.

Sign up to request clarification or add additional context in comments.

8 Comments

Thanks again for the help...the link u provided if for netbeans 6.9 but I am working with Netbeans 7.1....can you please please provide some good link for netbeans 7.1...thanks again
@RoseBEck: someone is preventing you from using a shell? Open it and run valgrind, it's by far the easiest way to do it
@akappa actually I am running a huge C++ project containing several files and folders..so I am a bit worried that will Valgrind work for my huge project...i know it works well for single files..but is it true that it works for huge project...also thanks for being kind and replying
Release Notes of 7.1.2 say: The C/C++ Profiling Tools were removed from the standard distribution of the IDE. and I think that you should try @akappa solution.
@RoseBEck: valgrind runs executable, so it doesn't care how many files and directories your project is composed of.
|
0

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.