 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Scott Meyers Guest
|
Posted: Thu Dec 18, 2003 8:53 am Post subject: Profiler for dynamic memory allocation? |
|
|
If I want to know where my program is spending its time, I can use a
profiler. Among other things, it "collapses" call chains such that if I
have
void f()
{
g();
h();
j();
}
I can find out how much time is spent in f without having to manually add
the times spent in g, h, and j.
But what if I want the same kind of information about dynamic memory
allocations? Suppose I want to know how much memory is allocated in f,
including in any of the functions directly or indirectly called by f. Are
there tools that report this kind of information?
Thanks,
Scott
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Dhruv Guest
|
Posted: Fri Dec 19, 2003 2:35 am Post subject: Re: Profiler for dynamic memory allocation? |
|
|
On Thu, 18 Dec 2003 03:53:54 -0500, Scott Meyers wrote:
[...]
| Quote: | Are
there tools that report this kind of information?
|
To cut a long story short, you should try valgrind.
<ripped from another post>
Try valgrind: http://www.tldp.org/HOWTO/Valgrind-HOWTO/
Regards,
-Dhruv.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Scott Meyers Guest
|
Posted: Fri Dec 19, 2003 7:57 am Post subject: Re: Profiler for dynamic memory allocation? |
|
|
On 18 Dec 2003 21:35:20 -0500, Dhruv wrote:
| Quote: | To cut a long story short, you should try valgrind.
|
Any chance you can elaborate a little? From the web site you cited:
As said above, memory management is prone to errors that are too hard to
detect. Common errors may be listed as:
Use of uninitialized memory
Reading/writing memory after it has been freed
Reading/writing off the end of malloc'd blocks
Reading/writing inappropriate areas on the stack
Memory leaks -- where pointers to malloc'd blocks are lost forever
Mismatched use of malloc/new/new[] vs free/delete/delete[]
Some misuses of the POSIX pthreads API
These errors usually lead to crashes. This is a situation where we need
Valgrind.
None of this is what I asked about (memory usage profiling), and a quick
scan of the Valgrind doc didn't reveal any obvious capabilities in that
area. Did I just overlook something?
Scott
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Dhruv Guest
|
Posted: Fri Dec 19, 2003 2:18 pm Post subject: Re: Profiler for dynamic memory allocation? |
|
|
On Fri, 19 Dec 2003 02:57:35 -0500, Scott Meyers wrote:
| Quote: | On 18 Dec 2003 21:35:20 -0500, Dhruv wrote:
To cut a long story short, you should try valgrind.
Any chance you can elaborate a little? From the web site you cited:
As said above, memory management is prone to errors that are too hard to
detect. Common errors may be listed as:
[...] |
| Quote: |
None of this is what I asked about (memory usage profiling), and a quick
scan of the Valgrind doc didn't reveal any obvious capabilities in that
area. Did I just overlook something?
|
But, that's the best you can get for free AFAIK. If you're willing to
shell out out some greens, then you could try:
http://www.codework.com/glowcode/product.html
Regards,
-Dhruv.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Jeff Greif Guest
|
Posted: Sat Dec 20, 2003 11:35 am Post subject: Re: Profiler for dynamic memory allocation? |
|
|
Though I've not used it for a few I'm pretty sure that Rational Quantify
(need $) provided memory allocation stats for the various code paths (e.g.
the cumulative memory allocation for f, with splits into what was allocated
in g,h,and j in your example), with ability to separate those from what was
allocated in other calls to g,h,j.
Jeff
"Scott Meyers" <Usenet (AT) aristeia (DOT) com> wrote
| Quote: | But what if I want the same kind of information about dynamic memory
allocations? Suppose I want to know how much memory is allocated in f,
including in any of the functions directly or indirectly called by f. Are
there tools that report this kind of information?
|
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Michael W. Hicks Guest
|
Posted: Sat Dec 20, 2003 11:43 am Post subject: Re: Profiler for dynamic memory allocation? |
|
|
"Scott Meyers" <Usenet (AT) aristeia (DOT) com> wrote
| Quote: | If I want to know where my program is spending its time, I can use a
profiler. Among other things, it "collapses" call chains such that if I
have
void f()
{
g();
h();
j();
}
I can find out how much time is spent in f without having to manually add
the times spent in g, h, and j.
But what if I want the same kind of information about dynamic memory
allocations? Suppose I want to know how much memory is allocated in f,
including in any of the functions directly or indirectly called by f. Are
there tools that report this kind of information?
Thanks,
Scott
|
Scott,
I believe a tool that might satisfy these requirements is Memory
Validator -- http://www.softwareverify.com. It tracks allocations at the
function level of granularity and much more (peak totals, running totals,
leaks, handles, etc.) It's definitely a profiler rather than just a leak
detector. It's a fairly heavy weight tool, so it might take a bit to find
the functionality you require. I believe this app is exclusively for the
Win32 environment, if that matters...
HTH,
- Mike
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|