Compare features among memory leak detection, memory growth detection and on-demand memory leak detection

    Intel® Inspector can detect regular memory leak.
It means that a block of memory is allocated, but never de-allocated when application exits. Usually the restriction of this feature is that we only know leaks until application exits. 

However some users’ application doesn’t terminate, it acts as sever application (process). Users want know two critical things that Inspector can:
    Detect memory growth 
It means that a block of memory is allocated (don’t know it will be de-allocated or not, later) and Inspector collects memory growth in specific time range when application is running. The benefit of this feature helped users to know memory consumption when application is running. Please note that memory growth is only warning message, not error message.  

    Detect on-demand memory leak
This is similar to memory growth, but only difference is that Inspector already knows allocated block of memory will NOT be de-allocated later. The reason is no pointer available to de-allocate memory.

There are three ways to set specific time range when application is running. 
1.    Use “Set Transaction Start” / “Set Transaction End” buttons, on GUI. These pair of buttons can be used for both memory growth detection and on-demand leak detection.
2.    Use “memory-growth-start”/” memory-growth-end” options, “reset-leak-tracking”/” find-leaks” options with “inspxe-cl command”

Please refer this article to know more detail.  

Here is an example to teach you to  
3.    Use APIs in ittnotify library to control specific time range to detect memory growth and/or on-demand memory leak.

Please see attach example code, test memory growth for 30s, then test on-demand memory leak for 20 minutes, you can use another console to terminate inspector…but partial results will be generated, which includes memory growth info & on-demand leak info.

1.    Build. # gcc -g memory.c /opt/intel/inspector_xe_2013/lib64/libittnotify.a -I/opt/intel/inspector_xe_2013/include/ -o memory -lpthread  -ldl
2.    # inspxe-cl -collect mi3 -- ./memory
3.    In other console: (after 30 seconds…) # inspxe-cl -command stop -r r000mi3/
4.    Inspector will display:

Run terminated abnormally. Some data may be lost. 
2 new problem(s) found 
    1 Memory growth problem(s) detected 
    1 Memory leak problem(s) detected

File memory.c1.22 KB
For more complete information about compiler optimizations, see our Optimization Notice.