By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,587 Members | 1,071 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,587 IT Pros & Developers. It's quick & easy.

Counting memory

P: 8
Is there a way calculating memory usage of program?

For example, I want to print to screen memory usage of my program in particular time periods.

Thanks.
Aug 9 '07 #1
Share this Question
Share on Google+
4 Replies


P: 84
Is there a way calculating memory usage of program?

For example, I want to print to screen memory usage of my program in particular time periods.

Thanks.
If you are using linux:
If you are able to save it I don't know, but if you just want to see how much active memory a program is using, you type "top" (without the ") and then look at RES and %CPU.
Hope it helps

On windows I don't know.
Aug 9 '07 #2

P: 8
If you are using linux:
If you are able to save it I don't know, but if you just want to see how much active memory a program is using, you type "top" (without the ") and then look at RES and %CPU.
Hope it helps

On windows I don't know.

I will produce new objects of class, dynamically(I will add them to a vector) I want to cut off producing new objects when for example 512 MB memory is used.

Thanks anyway :)
Aug 9 '07 #3

P: 36
I will produce new objects of class, dynamically(I will add them to a vector) I want to cut off producing new objects when for example 512 MB memory is used.

Thanks anyway :)
You can get the size of the objects and then calculate how many it would take to reach your size limit. Then just stop when you reach that number. Or keep a running total in a variable and quit when you reach your limit. It's probably not exactly what you want to do, though...
Aug 9 '07 #4

RRick
Expert 100+
P: 463
In C++, you can overload the global new and delete operators. The C++ book says this is not for the faint of heart, so beware.

Try this link: http://www.relisoft.com/book/tech/9new.html

My idea is to overload new/delete with others that store/update memory info and then call the original new/delete. I'm not sure how the last step is performed.
Aug 9 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.