 |
|
 |
|
|
 |
C++ Library call to gather process characteristics? pstat? |
 |
 |
|
|
02-08-07 12:23 AM
I have a piece of code that needs fundamental leak analysis, dbx for
this current problem is non-functional.
The basic question is, is there a unix library that I can link into
the executable that will give me a structure of process
characteristics like resident memory, total memory etcetera?
I seem to remember "pstat()" being the call but I can find no
reference to this in the Solaris documentation.
What I really want to be able to do is have the process be able to
(through a function call) publish it's own memory usage
characteristics at mile-stone marks in the code so memory usage can be
tracked relative to code lines in the program.
Any help on this problem will be appreciated. Thanks in advance for
the help.
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: C++ Library call to gather process characteristics? pstat? |
 |
 |
|
|
02-08-07 12:23 AM
On 7 Feb 2007 12:11:53 -0800, LTSnyder@x3ci.com wrote:
> I have a piece of code that needs fundamental leak analysis, dbx for
> this current problem is non-functional.
> The basic question is, is there a unix library that I can link into
> the executable that will give me a structure of process
> characteristics like resident memory, total memory etcetera?
If you are using (or have access to) a fairly recent Solaris, try the
`libumem' allocator. It has very nice features for tracking down and
analyzing where memory allocation problems exist.
For a mini-guide about libumem and its use, see:
http://access1.sun.com/techarticles/libumem.html
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: C++ Library call to gather process characteristics? pstat? |
 |
 |
|
|
02-08-07 12:23 AM
On Feb 7, 12:11 pm, LTSny...@x3ci.com wrote:
> I have a piece of code that needs fundamental leak analysis, dbx for
> this current problem is non-functional.
> The basic question is, is there a unix library that I can link into
> the executable that will give me a structure of process
> characteristics like resident memory, total memory etcetera?
>
> I seem to remember "pstat()" being the call but I can find no
> reference to this in the Solaris documentation.
> What I really want to be able to do is have the process be able to
> (through a function call) publish it's own memory usage
> characteristics at mile-stone marks in the code so memory usage can be
> tracked relative to code lines in the program.
>
> Any help on this problem will be appreciated. Thanks in advance for
> the help.
Whats the platform? On linux IIRC some of the information is in the /
proc filesystem and you can read it like a file.
Ivan Novick
http://www.0x4849.net
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: C++ Library call to gather process characteristics? pstat? |
 |
 |
|
|
02-09-07 12:20 AM
On Feb 7, 7:36 pm, "Ivan Novick" <ivan.d.nov...@gmail.com> wrote:
> On Feb 7, 12:11 pm, LTSny...@x3ci.com wrote:
>
>
>
>
> Whats the platform? On linux IIRC some of the information is in the /
> proc filesystem and you can read it like a file.
>
> Ivan Novickhttp://www.0x4849.net
Sorry about missing the Details, this is on Solaris 9 on a Sunfire
box.
The reason I want a means to access the total memory footprint from a
library call is because there is a chance that this is a logical bug
in allocation as per our implementation of a STL list in which case it
is not any actual leak but rather just abusive use of memory by a
particular funtion/class/operation.
Being able to create milestones in the code with a memory usage report
woudl be a quick and dirty way to norrow down a logical memory use
flaw in the code.
> If you are using (or have access to) a fairly recent Solaris, try the
> `libumem' allocator. It has very nice features for tracking down and
> analyzing where memory allocation problems exist.
While `libumem' is very useful for tracking down code leaks, overruns,
etcetera it does not allow me to get the "memory footprint" I state I
want above in this message.
Leland T. Snyder
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: C++ Library call to gather process characteristics? pstat? |
 |
 |
|
|
02-09-07 12:20 AM
LTSnyder@x3ci.com wrote:
>
> Sorry about missing the Details, this is on Solaris 9 on a Sunfire
> box.
> The reason I want a means to access the total memory footprint from a
> library call is because there is a chance that this is a logical bug
> in allocation as per our implementation of a STL list in which case it
> is not any actual leak but rather just abusive use of memory by a
> particular funtion/class/operation.
> Being able to create milestones in the code with a memory usage report
> woudl be a quick and dirty way to norrow down a logical memory use
> flaw in the code.
>
Have you tried providing your own implementation of the global new and
delete operators? Assuming your application isn't doing anything nasty
like calling malloc, that should give you all the information you require.
--
Ian Collins.
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: C++ Library call to gather process characteristics? pstat? |
 |
 |
|
|
02-09-07 12:20 AM
On Feb 8, 3:37 pm, Ian Collins <ian-n...@hotmail.com> wrote:
> LTSny...@x3ci.com wrote:
>
>
> Have you tried providing your own implementation of the global new and
> delete operators? Assuming your application isn't doing anything nasty
> like calling malloc, that should give you all the information you require.
>
> --
> Ian Collins.
That could be done of course, a lot of code is libraries included as
archives that I do not with to recompile unless I need to.
I guess the answer is that there is no library method to provide a
memory footprint (res/total) of a particular pid.
I'll use the suggested solutions.
-Leland T. Snyder
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: C++ Library call to gather process characteristics? pstat? |
 |
 |
|
|
02-09-07 12:20 AM
LTSnyder@x3ci.com wrote:
> On Feb 8, 3:37 pm, Ian Collins <ian-n...@hotmail.com> wrote:
>
>
> That could be done of course, a lot of code is libraries included as
> archives that I do not with to recompile unless I need to.
That won't be necessary, if you provide your own new/delete they will
replace the defaults at link time. I use my own version for all my
testing to check for leaks and to profile of allocation sizes.
--
Ian Collins.
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: C++ Library call to gather process characteristics? pstat? |
 |
 |
|
|
02-09-07 12:20 AM
On Feb 8, 4:08 pm, Ian Collins <ian-n...@hotmail.com> wrote:
> LTSny...@x3ci.com wrote:
>
>
>
>
>
> That won't be necessary, if you provide your own new/delete they will
> replace the defaults at link time. I use my own version for all my
> testing to check for leaks and to profile of allocation sizes.
>
> --
> Ian Collins.- Hide quoted text -
>
> - Show quoted text -
Sounds great, but how do you overload (or pick up an alternate
definition via shared object) if the "new" allocation routine/method/
wrapper if it is a keyword of the C++ ANSI spec?
Does this imply that new is being pulled from a shared object and that
I can "swap" in and out this rewrite of new by simply changing if the
true shared object defining new, or my hack, is found first?
Can you point me to an example of this?
-Leland T. Snyder
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: C++ Library call to gather process characteristics? pstat? |
 |
 |
|
|
02-09-07 12:20 AM
LTSnyder@x3ci.com wrote On 02/08/07 15:24,:
> On Feb 7, 7:36 pm, "Ivan Novick" <ivan.d.nov...@gmail.com> wrote:
>
>
>
> Sorry about missing the Details, this is on Solaris 9 on a Sunfire
> box.
> The reason I want a means to access the total memory footprint from a
> library call is because there is a chance that this is a logical bug
> in allocation as per our implementation of a STL list in which case it
> is not any actual leak but rather just abusive use of memory by a
> particular funtion/class/operation.
> Being able to create milestones in the code with a memory usage report
> woudl be a quick and dirty way to norrow down a logical memory use
> flaw in the code.
One thing you could do is read /proc/self/map and add
up the address mappings ("man -s4 proc"). That's fairly
crude because it doesn't distinguish malloced/newed memory
from freed/deleted memory: it just reports what's mapped
in your address space. If you've got a leak, though, the
total mapped space should increase over time.
--
Eric.Sosman@sun.com
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: C++ Library call to gather process characteristics? pstat? |
 |
 |
|
|
02-09-07 12:20 AM
LTSnyder@x3ci.com wrote:
> On Feb 8, 4:08 pm, Ian Collins <ian-n...@hotmail.com> wrote:
>
Please trim signatures, it make for less crud.[vbcol=seagreen]
>
> Sounds great, but how do you overload (or pick up an alternate
> definition via shared object) if the "new" allocation routine/method/
> wrapper if it is a keyword of the C++ ANSI spec?
> Does this imply that new is being pulled from a shared object and that
> I can "swap" in and out this rewrite of new by simply changing if the
> true shared object defining new, or my hack, is found first?
> Can you point me to an example of this?
>
The global new and delete operators are provide by the C++ runtime
library. They implemented as week symbols, so if you code contains
these operators, they will be used by the linker in preference to those
in the runtime library.
The exact implementation isn't defined by the standard, but the ability
to replace the global new and delete operators is.
--
Ian Collins.
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
|
Sponsored Links |
 |
 |
|
|
 |
All times are GMT. The time now is 09:56 AM. |
 |
|
|
 |
|
 |
|
|
 |
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
|
|
|
|
Medical and Health forum | Computer Games Reviews | Graphics design forum
|
 |
|
 |
|