[dtrace-discuss] allocated buffer in real time

Adam Leventhal ahl at eng.sun.com
Wed Jun 6 10:56:11 PDT 2007


Hi Fabien,

I'm a bit confused by your script. Why are you performing the copyin()? Also,
if this is a multi-threaded application on an MP maching your use of global
variable will cause problems.

What information are you trying to see exactly? It sounds like you might be
interested in checking for leaks in which case libumem is a far better
solution.

Adam

On Wed, Jun 06, 2007 at 04:28:51AM -0700, Lafontaine wrote:
> hello!
> I am trying to display in a shell the allocated buffer by a process in real time (every 10 seconds) to see the memory area which are never freed.
> My script is: (I found it at : http://www.opensolaris.org/jive/thread.jspa?messageID=66432&#66432 )
> 
> dtrace:::BEGIN
> {
> @bufs[1] = sum(walltimestamp/1000000);
> }
> 
> pid$1::*__1cKmem_alloc_6FkIkiknJBoolean_t_1pkc_pv_*:return
> {
> x = (walltimestamp/1000000);
> bufs[arg1] = x;    /*arg1 is the address of the allocation*/
> @bufs[arg1] = sum(x);
> }
> 
> pid$1::*__1cJmem_free_6FkIppvkipkc_nJRC_Code_t__*:entry
> /bufs[*(uint32_t *)copyin(arg1,sizeof(uint32_t))]/
> {
> this->add=*(uint32_t *)copyin(arg1,sizeof(uint32_t));    /*because arg1 is an address of the freed memory adress in this function*/
> y=bufs[this->add];
> @bufs[this->add] = sum(-y);
> bufs[this->add] = 0;
> }
> 
> dtrace:::END
> {
> @bufs[3] = sum(walltimestamp/1000000);
> }
> 
> I obtain that:
>         1    1181135596760
>           3384348    1181135597649
>           3384124    1181135597649
>         3    1181135598159
>           3384236    2362271194608
>           2886084    4724542389906
>           2868668    4724542389906
>           2885884    4724542389906
>           2885684    5905677986745
>           2885852    5905677986745
>   2885852   -5905677986745
>   2885684   -5905677986745
>   2868668   -4724542389906
>   2886084   -4724542389906
>   2885884   -4724542389906
>   3384236   -1181135596809
> 
> why does it make a diffence between @bufs[arg1] and @bufs[this->add] when arg1 and this->add are the same? 
> Do you know a better way to do what I need? (display the not freed area memories)
> 
> Thank you for your help, ask me if you don't understand something.
> 
> Fabien.
> --
> This message posted from opensolaris.org
> _______________________________________________
> dtrace-discuss mailing list
> dtrace-discuss at opensolaris.org

-- 
Adam Leventhal, Solaris Kernel Development       http://blogs.sun.com/ahl


More information about the dtrace-discuss mailing list