solaris 检测内存泄露
测试步骤:1、编译测试测试程序testsyb,里面包含建立连接释放连接的操作。
2、依次设置如下环境变量
export LD_PRELOAD_32=libumem.so
export UMEM_DEBUG=default,audit=25
export UMEM_LOGGING=transaction
3、运行程序testsyb
4、ps -ef|grep testsyb 获取到进程ID
5、使用mdb attach到该进程
mdb -p 进程ID
6、使用mdb的命令 ::findleaks -dvf 打印内存泄露点以及堆栈
>::findleaks -dvf
下面是显式的泄露信息以及栈
CACHE LEAKED BUFCTL CALLER
00066508 9 00077360 libsybcomn_r.so`_sybcsi_init_system_policy+0x180
00066c88 9 00099ea0 libsybcomn_r.so`comn_create_mutex+0xc
00066788 1 000adb80 libsybcomn_r.so`do_provider_init+0x13c
00066508 1 001c9400 libsybcomn_r.so`do_provider_init+0x13c
umem_alloc_48 leak: 9 buffers, 48 bytes each, 336 bytes total
ADDR BUFADDR TIMESTAMP THREAD
CACHE LASTLOG CONTENTS
1dc280 1d9500 64d39efbc386 1
66c88 4a7a8 0
libumem.so.1`umem_cache_alloc+0x13c
libumem.so.1`umem_alloc+0x60
libumem.so.1`malloc+0x28
libumem.so.1`calloc+0x58
libsybcomn_r.so`comn_create_mutex+0xc
libsybcomn_r.so`comn__csi_mutex_create+4
libsybcomn_r.so`_sybcsi_init_system_policy+0x1ac
libsybcomn_r.so`sybcsi_factory_create+0x60
libsybcomn_r.so`com__csi_factory_alloc+0x314
libsybcomn_r.so`com_extended_alloc_factory+0x14
libsybct_r.so`ct__string_extended_encryption+0x18
libsybct_r.so`ct__api_password+0x1a0
libsybct_r.so`ct_con_props+0x1c4
libsqlapi.so`__1cQIsyb15ConnectionHConnect6MrknISAString_33_v_+0x384
libsqlapi.so`__1cMSADataSourceTGetPooledConnection6MnOSAAutoCommit_t_b_nSSAPool
edConnection__+0xf4
main+0x5d0
_start+0x108
umem_alloc_24 leak: 9 buffers, 24 bytes each, 168 bytes total
ADDR BUFADDR TIMESTAMP THREAD
CACHE LASTLOG CONTENTS
209220 2017b0 64d39efbad10 1
66508 4a71c 0
libumem.so.1`umem_cache_alloc+0x13c
libumem.so.1`umem_alloc+0x60
libumem.so.1`malloc+0x28
libsybcomn_r.so`_sybcsi_init_system_policy+0x180
libsybcomn_r.so`sybcsi_factory_create+0x60
libsybcomn_r.so`com__csi_factory_alloc+0x314
libsybcomn_r.so`com_extended_alloc_factory+0x14
libsybct_r.so`ct__string_extended_encryption+0x18
libsybct_r.so`ct__api_password+0x1a0
libsybct_r.so`ct_con_props+0x1c4
libsqlapi.so`__1cQIsyb15ConnectionHConnect6MrknISAString_33_v_+0x384
libsqlapi.so`__1cMSADataSourceTGetPooledConnection6MnOSAAutoCommit_t_b_nSSAPool
edConnection__+0xf4
main+0x5d0
_start+0x108
页:
[1]