Solaris下使用mdb檢查內存洩露
步驟一:
UMEM_DEBUG=default UMEM_LOGGING=transaction LD_PRELOAD=libumem.so.1 ./spAgent &
www.2cto.com
步驟二:
-bash-3.00$ mdb -p 16546 //上面得到進程ID
Loading modules: [ ld.so.1 libumem.so.1 libc.so.1 ]
步驟三:
-bash-3.00$ mdb -p 16546
Loading modules: [ ld.so.1 libumem.so.1 libc.so.1 ]
> ::findleaks //查找內存洩露
CACHE LEAKED BUFCTL CALLER
00484008 11489 00a7f428 libstdc++.so.6.0.3`_Znwj+0x1c
----------------------------------------------------------------------
Total 11489 buffers, 5147072 bytes
www.2cto.com
步驟四:
> 00a7f428::bufctl_audit //查看最後使用這內存地址的調用堆棧
ADDR BUFADDR TIMESTAMP THREAD
CACHE LASTLOG CONTENTS
a7f428 a85a00 2185ef54480864 47
484008 3165dc 0
libumem.so.1`umem_cache_alloc+0x13c
libumem.so.1`umem_alloc+0x60
libumem.so.1`malloc+0x28
libstdc++.so.6.0.3`_Znwj+0x1c
_ZN6RXConn17HandleSMPPDeliverEPK7AIChunki+0x510
_ZN6RXConn10RecvThreadEv+0x6c4
_ZN6RXConn4RecvEPv+0x20
libc.so.1`_lwp_start
通過以上步驟基本可以定位內存洩露發生在xx函數。