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𐎀 ) 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
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𐎀 ) > > 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
Hello Adam! Thank you for your answer. I don''t know libumem very well but I''m not sure it is very usefull for my application: the process I watch use internal functions to allocate (__1cKmem_alloc_6FkIkiknJBoolean_t_1pkc_pv) and free memory (*__1cJmem_free_6FkIppvkipkc_nJRC_Code_t__*). For the allocation function, arg1 is the address to allocate, and for the free function, arg1 is a pointer, that''s why I use copyin on this address to see the real address of the allocation. Am I clear? And it works because when I printf arg1 in the allocation function and *(uint32_t *)copyin(arg1,sizeof(uint32_t)) in the free function, I get the same value. But the aggregation @bufs doesn''t seem to think that... Any solutions? I need to use Dtrace because I can''t stop the running process I want to analyse... Thank you for your patience ;-) Fabien. -- This message posted from opensolaris.org
Hi! I found a solution: pid$1::*__1cKmem_alloc_6FkIkiknJBoolean_t_1pkc_pv_*:return { printf("allocmem: #%x \n",arg1); x = arg1; bufs[x] = x; @bufs[x] = sum(x); } pid$1::*__1cJmem_free_6FkIppvkipkc_nJRC_Code_t__*:entry /bufs[*(uint32_t *)copyin(arg1,sizeof(uint32_t))]/ { self->add=*(uint32_t *)copyin(arg1,sizeof(uint32_t)); printf("freemem: #%x \n",self->add); y=self->add; @bufs[bufs[self->add]] = sum(-y); bufs[self->add] = 0; } if the memory is allocated, the value is the adress. if the memory is freed, the value is 0. -- This message posted from opensolaris.org