[dtrace-discuss] allocated buffer in real time

Lafontaine fablaf61 at hotmail.com
Wed Jun 6 04:28:51 PDT 2007


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


More information about the dtrace-discuss mailing list