473,505 Members | 15,381 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Counting memory

8 New Member
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
4 1491
sanctus
84 New Member
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
metdos
8 New Member
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
Matthew Page
36 New Member
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
463 Recognized Expert Contributor
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

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

Similar topics

6
2164
by: Elbert Lev | last post by:
Please correct me if I'm wrong. Python (as I understand) uses reference counting to determine when to delete the object. As soon as the object goes out of the scope it is deleted. Python does...
7
5178
by: mikester | last post by:
First off I'll say - I am a bad perl programmer. I want to be better and with your help I'll get there and then be able to contribute more here. That being said, I have a simple problem...
6
1676
by: jabailo | last post by:
Which would be faster for counting lines in a StreamReader: (a) iterate through a file using .ReadLine() and adding to a counter, i++ (b) doing a .ReadToEnd() and then using an IndexOf() method...
1
3227
by: Tony Johansson | last post by:
Hello Experts! I reading a book called programming with design pattern revealed by Tomasz Muldner and here I read something that I don't understand completely. It says "A garbarage...
1
1863
by: Tony Johansson | last post by:
Hello Experts! I reading a book called programming with design pattern revealed by Tomasz Muldner and here I read something that I don't understand completely. It says "A garbarage...
11
1859
by: Hur | last post by:
hi i ask two questions......someone can tell me i an a linux gcc user and wanna know that - how much physical memory is used for my c code ? and another one is - i need a (standard)...
4
4177
by: aaronfude | last post by:
Hi, Please consider the following class (it's not really my class, but it's a good example for my question): class Vector { int myN; double *myX; Vector(int n) : myN(n), myX(new double) { }...
3
1812
by: lord trousers | last post by:
I'm currently replacing the Quake 3 game code (not the rendering, sound, or collision detection pieces) with Python. I've now successfully loaded Python modules and made callbacks to them, rendered...
2
1445
by: StevePBurgess | last post by:
Hi. I have a script that runs every night on my server that counts the hits for my hosted RSS feeds and puts the information into a MySQL table which then feeds the live(ish) statistics graphs on...
14
2063
by: Dan | last post by:
Is this discouraged?: for line in open(filename): <do something with line> That is, should I do this instead?: fileptr = open(filename) for line in fileptr: <do something with line>
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7018
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5613
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4699
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.