2013-12-13 6 views
0

나는 메모리 사용에 대한 성가신 버그를 충족, 그래서 나는Solaris 10에서 Dtrace를 사용하여 malloc을 확인하는 방법은 무엇입니까?

나는 다음과 같은 명령을 사용 솔라리스 10에서의 malloc와 무료를 확인의 DTrace 사용하려는

dtrace -l | grep malloc 

출력은 다음과 같습니다

7000  fbt    unix      prom_malloc entry 
7001  fbt    unix      prom_malloc return 
7141  fbt   genunix      cacl_malloc entry 
7142  fbt   genunix      cacl_malloc return 
12319  fbt   genunix     rmallocmap_wait entry 
12320  fbt   genunix     rmallocmap_wait return 
13078  fbt   genunix      rmalloc_wait entry 
13079  fbt   genunix      rmalloc_wait return 
13526  fbt   genunix      rmallocmap entry 
13527  fbt   genunix      rmallocmap return 
16846  fbt   genunix       rmalloc entry 
16847  fbt   genunix       rmalloc return 
25931  fbt    tmpfs      tmp_memalloc entry 
25932  fbt    tmpfs      tmp_memalloc return 

malloc이없는 것 같습니다.

Solaris Internal을 확인하고 malloc 호출 sbrk를 발견했습니다. 그래서 다음 명령을 사용합니다 :

dtrace -l | grep sbrk 

그러나 아무것도 찾을 수 없습니다.

그래서 Solaris 10에서 Dtrace를 사용하여 malloc을 확인할 수 있습니까?

+1

에 봐 :

이 스크립트는 프로그램에 의해 모든 mallocfree 호출을 추적합니다 : http : //theunixshell.blogspot.com/2013/11/finding-memory-leaks-on-solaris-is-no.html – Vijay

+0

@ Vijay : 귀하의 의견에 대해 대단히 감사 드리며 매우 멋진 도구입니다! –

+0

@ Vijay : 도구의 소스 코드를 기꺼이 열어 볼 의향이 있습니까? –

답변

3

가 이미 솔라리스 메모리 누수를 식별하는 데 필요한 논리를 구현하는 다양한 도구,

  • libumem을 (다음 UMEM_DEBUG=default UMEM_LOGGING=transaction LD_PRELOAD=libumem.so.1mdb's ::findleaks) & MDB
  • DBX (check -leaks)

은 다음을 수행해야 여전히 dtrace 방법을 가고 싶다면, 당신은 당신이 pid 공급자를 사용하여 메모리 누수가 의심되는 프로세스를 추적해야합니다. dtrace -l으로 커널 프로브를 검색했지만 아무 것도 발견하지 못했습니다. 커널이 malloc 또는 brk을 구현하지 않기 때문에 예상됩니다. 이들은 C 표준 라이브러리에있는 유저 랜드 기능입니다. 이 도구는 당신을 위해 도움이 될 것입니다, 더 깊이있는 예를 들어

dtrace -qn ' 
pid$target:libc:malloc:entry { 
     self->size=arg0; 
} 
pid$target:libc:malloc:return /self->size/ { 
     printf("malloc(%d)=%p\n",self->size,arg1); 
     self->size=0; 
} 
pid$target:libc:free:entry { 
     printf("free(%p)\n",arg0); 
} 
' -c program_to_trace 

http://ewaldertl.blogspot.fr/2010/09/debugging-memory-leaks-with-dtrace-and.htmlhttp://www.joyent.com/blog/bruning-questions-debugging 것 같아요