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

peak memory usage

P: n/a
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
Share this Question
Share on Google+
11 Replies


P: n/a
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

P: n/a
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

P: n/a
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.programmer.

--
Ian Collins.
Mar 21 '07 #4

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
On Wed, 21 Mar 2007 09:54:46 -0700, Rares Vernica wrote:
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.
If memory serves correctly, Massif produces a plot of memory consumption
over time. Would that get you at least close enough to what you need?

- Micchael
Mar 21 '07 #11

P: n/a
Michael Ekstrand wrote:
On Wed, 21 Mar 2007 09:54:46 -0700, Rares Vernica wrote:
> 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.

If memory serves correctly, Massif produces a plot of memory consumption
over time. Would that get you at least close enough to what you need?

- Micchael
Yes, you are correct, it produces a plot, but is difficult to get the
peak exactly.

Thanks,
Ray
Mar 21 '07 #12

This discussion thread is closed

Replies have been disabled for this discussion.