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 ]
步骤三:
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
libumem.so.1`umem_cache_alloc+0x13c
libstdc++.so.6.0.3`_Znwj+0x1c
libc.so.1`_lwp_start
通过以上步骤基本可以定位内存泄露发生在xx函数。
查看更多关于Solaris下使用mdb检查内存泄露 - Linux操作系统:U的详细内容...