473,657 Members | 2,300 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 1495
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.co m/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
2174
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 not use garbage collection (as Java does). So if the script runs a loop: for i in range(100): f = Obj(i)
7
5184
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 compounded by file size. I have a PIX that logs to my syslog server for a ton of items - my logs sizes get extremely large; ~13 GIGABYTEs daily and they are rotated daily.
6
1706
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 to count the occurances of \r\n (c) doing a .ReadToEnd() and using a RegEx to count the number of occurances of \r\n
1
3247
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 collector, such as the one used in Java, maintains a record of whether or not an object is currentlys being used. An unused object is tagged as garbage,
1
1873
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 collector, such as the one used in Java, maintains a record of whether or not an object is currentlys being used. An unused object is tagged as garbage,
11
1873
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) function to count the number of '1' for example,
4
4193
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) { } double &operator()(int i) { return myX; }
3
1818
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 maps, written some fly-through code, and embedded a Python interactive mode into the console (which is way, way cool). It's my first C API project, and I want to make sure I've got my reference counting right. I *could* go through the API docs...
2
1455
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 the site. I am using: $log=implode('',file("access_log")); $count=substr_count($log,"GET /feed7.xml"); for example to count the number of times feed7.xml is requested.
14
2076
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
8411
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8323
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8838
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8513
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8613
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7351
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4173
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.