473,765 Members | 1,964 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

peak memory usage

Hi,

What is the right way/tool to find the peak memory usage of a C++ program?

I tried Valgrind but is does not seem to be able to answer my question.

Thanks a lot,
Ray
Mar 21 '07 #1
11 5942
Rares Vernica wrote:
Hi,

What is the right way/tool to find the peak memory usage of a C++ program?
Either do it yourself with a custom allocator, or use whatever tools
your operating environment provides.

--
Ian Collins.
Mar 21 '07 #2
Ian Collins wrote:
Rares Vernica wrote:
>Hi,

What is the right way/tool to find the peak memory usage of a C++ program?
Either do it yourself with a custom allocator, or use whatever tools
your operating environment provides.
Can you please name a few tools? I am using Linux.

I know "top" shows the memory usage, but it shows it in real time and it
is difficult to get the peak.

Thanks,
Ray
Mar 21 '07 #3
Rares Vernica wrote:
Ian Collins wrote:
>Rares Vernica wrote:
>>Hi,

What is the right way/tool to find the peak memory usage of a C++
program?
Either do it yourself with a custom allocator, or use whatever tools
your operating environment provides.

Can you please name a few tools? I am using Linux.
I prefer the custom allocator approach, as for tools, you should ask on
a Linux development group or comp.unix.progr ammer.

--
Ian Collins.
Mar 21 '07 #4
Can you please name a few tools? I am using Linux.
IIRC memusage. Puts out a log or even a png graphic with the memory
usage. Used it a lot some time ago for debugging purposes
Michael

Mar 21 '07 #5
Rares Vernica wrote:
Hi,

What is the right way/tool to find the peak memory usage of a C++ program?

I tried Valgrind but is does not seem to be able to answer my question.

Thanks a lot,
Ray
You didn't try valgrind hard enough, search 'messif'. Valgrind does give
you detailed memory usage. Why wouldn't it? All your memory
allocation/deallocation are detoured through valgrind.

Fei
Mar 21 '07 #6
Rares Vernica wrote:
<OT>
I know "top" shows the memory usage, but it shows it in real time and it
is difficult to get the peak.
Well, "man top" says top has batch mode operation, perhaps you could
use that?

</OT>
Mar 21 '07 #7
Fei Liu wrote:
Rares Vernica wrote:
>Hi,

What is the right way/tool to find the peak memory usage of a C++
program?

I tried Valgrind but is does not seem to be able to answer my question.

Thanks a lot,
Ray
You didn't try valgrind hard enough, search 'messif'. Valgrind does give
you detailed memory usage. Why wouldn't it? All your memory
allocation/deallocation are detoured through valgrind.

Fei
I especially tried Massif.

Quote from the Valgrind mailing list:

"I would like to know just the size of the memory my program is using.
Does the following information from memcheck answer my question?

==14776== malloc/free: 594,317 allocs, 594,317 frees, 15,403,721 bytes
allocated.

No. That's the total allocated. You want the peak, I presume.
If not, how can I compute the total memory usage from this massif
output:
>
==14494== Total spacetime: 522,204,199,298 ms.B

You can't, unfortunately.

---
Yes, I would like to know the peak.

Is there a way to find it out?
Not without modifying Massif.
"

Ray
Mar 21 '07 #8
Jacek Dziedzic wrote:
Rares Vernica wrote:
<OT>
>I know "top" shows the memory usage, but it shows it in real time and
it is difficult to get the peak.

Well, "man top" says top has batch mode operation, perhaps you could
use that?

</OT>
Even in batch mode, I would need to run top exactly when the memory
usage in my program is at peak.

Thanks,
Ray
Mar 21 '07 #9
Michael Oswald wrote:
>Can you please name a few tools? I am using Linux.


IIRC memusage. Puts out a log or even a png graphic with the memory
usage. Used it a lot some time ago for debugging purposes
Michael
memusage seems to do the job.

Thanks a lot,
Ray
Mar 21 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3674
by: rbt | last post by:
Would a Python process consume more memory on a PC with lots of memory? For example, say I have the same Python script running on two WinXP computers that both have Python 2.4.0. One computer has 256 MB of Ram while the other has 2 GB of Ram. On the machine with less Ram, the process takes about 1 MB of Ram. On the machine with more Ram, it uses 9 MB of Ram. Is this normal and expected behavior?
2
3346
by: Mike Peretz | last post by:
I am trying to optimize my C# program, but no matter what I try the application keeps eating memory. I verified all the references and even got special software to count references. I made sure all the reference count reaches zero for all the objects that are no longer used. I also call Dispose as much as possible. Regardless, the memory is not freed. Even if I force the GC, some memory gets freed but not much.
2
460
by: tomvr | last post by:
Hello I have noticed some 'weird' memory usage in a vb.net windows app The situation is as follows I have an app (heavy on images) with 2 forms (actually there are more forms and on starting the app I load some things into memory for global use of the app but I'll use only 2 starting forms to explain the situation) situation 1 start app with form 1 (72mb memory usage), show form 2 and hide form 1 (89 mb memory usage
6
3278
by: Tom | last post by:
We have a VERY simple .NET C# Form Application, that has about a 23MB Memory Footprint. It starts a window runs a process and does a regular expression. I have done a GC.Collect to make sure that, no memory is lying around. GC reports only 84k of allocations. Starting 5-10 of this apps is going to start taking a considerable amount of memory. Is there a way to reduce this? Tom
2
422
by: Jarvis | last post by:
I've made a testing program to test the memory usage of some Data Forms. I create a MDI parent form with one single MDI child form, which is a Data Form generated by .NET Data Form Wizard. To test the stuff, I keep to open that child data form for about 10 times. the memory usage shown in GC and task manager both increase. Then I close all those forms. and perform GC collect. The memory usage shown in GC falls, however, the memory...
3
4148
by: Ian Taite | last post by:
Hello, I'm exploring why one of my C# .NET apps has "high" memory usage, and whether I can reduce the memory usage. I have an app that wakes up and processes text files into a database periodically. What happens, is that the app reads the contents of a text file line by line into an ArrayList. Each element of the ArrayList is a string representing a record from the file. The ArrayList is then processed, and the arraylist goes out of...
3
2286
by: Xiangliang Meng | last post by:
Hi, all. In 1998, I graduated from Computer Science Dept. in a university in China. Since then, I've been using C Language for almost 6 years. Although I'm using C++ in my current job, I'm also interested in understanding C more and deeper at the same time. In the past half year, I decide to improve myself on C, read some books on C and digest some posts on comp.lang.c and comp.lang.c++. Now, I feel I have a better insight on C than...
20
4239
by: Philip Carnstam | last post by:
How come .Net applications use so much memory? Every application I compile uses at least 10 MB of memory, even the ones consisting of only a form and nothing else. If I minimize them though the memory usage drops to a couple hundred KB. Why? Is there anything I should to to prevent this? I have compiled in release and deactivated all forms of debugging, I think! Thanks, Philip
1
1551
by: redefined.horizons | last post by:
I was intriuged by the concept of Python Eggs and some of the work that has been done on PEAK. http://peak.telecommunity.com/ However, I think PEAK might be overkill for the particular design I am considering. Is anyone using just part of PEAK in their Python development. Are there alternative distribution enhancements for Python besides PEAK that I might take a look at?
0
9568
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
9399
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
10161
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
9955
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
9833
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
6649
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5275
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
5421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3924
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 we have to send another system

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.