Find the memory usage, footprint, leak

来源:互联网 发布:jdbc批量删除数据 编辑:程序博客网 时间:2024/05/16 06:54

Heap memory usage footprint:

Windows: Microsoft has UMDH tool to dump memory usage in heap. It contains the memory allocation, size and where(call statck to alloc this memory)

For example:

490 bytes + 30 at 1433D0 by BackTrace16
 78EDD036
 78D58EE6
 78D57BAC
 78D58E9E
 78D57AC0
 78EDEF73
 78ED7946
 78ED62D8
 78ED6416
 78EF3925
 78D59630


628 bytes + 38 at 143890 by BackTrace17
 78EDD036
 78D58F18
 78D57BAC
 78D58E9E
 78D57AC0
 78EDEF73
 78ED7946
 78ED62D8
 78ED6416
 78EF3925
 78D59630

 

Linux: /proc/pid/smaps or /proc/pid/maps has memory allocation and size information, but no call stack. smaps had more detail information than maps.

For example:

00110000-0012c000 r-xp 00000000 08:01 469893     /opt/CloudDesktopHost/lib/libcrutil.so
Size:                112 kB
Rss:                 112 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:        24 kB
Private_Dirty:        88 kB
Referenced:          112 kB
0012c000-0012d000 rw-p 0001c000 08:01 469893     /opt/CloudDesktopHost/lib/libcrutil.so
Size:                  4 kB
Rss:                   4 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:         0 kB
Private_Dirty:         4 kB
Referenced:            4 kB

 

Memory leak check:

Purify, valgrind(Linux)