Difference between revisions of "Heap Memory Profile Probe"

From OC Systems Wiki!
Jump to: navigation, search
m (heap Memory Profile Report)
m (Usage)
Line 14: Line 14:
  
 
The heap profile information is collected in memory and periodically logged in snapshots logged to the APD file for later processing by [[AUG_Tools_Reference#apformat|apformat]].  At format time a report is generated for each snapshot and an overall summary for the whole program which details the number and duration of allocations and deallocation of objects of different sizes.  The data is tabulated and displayed in histograms.  The reports are designed to allow you to identify areas of heavy heap usage based on object sizes rather than specific objects.  This analysis may be followed up by custom probes to discover where the application is allocating objects of a specific size, for example.
 
The heap profile information is collected in memory and periodically logged in snapshots logged to the APD file for later processing by [[AUG_Tools_Reference#apformat|apformat]].  At format time a report is generated for each snapshot and an overall summary for the whole program which details the number and duration of allocations and deallocation of objects of different sizes.  The data is tabulated and displayed in histograms.  The reports are designed to allow you to identify areas of heavy heap usage based on object sizes rather than specific objects.  This analysis may be followed up by custom probes to discover where the application is allocating objects of a specific size, for example.
 +
 +
The default parameters provide good initial coverage of heap object sizes by defining bucket sizes that increase by powers of two. Object smaller than the smallest bucket size are tallied in the the smallest bucket and object larger than the largest bucket size are tallied in the largest bucket.  You can focus on specific object size by specifying a starting bucket size and the number of buckets to use with linearly increasing sizes.
  
 
=== Profile UAL Parameters ===
 
=== Profile UAL Parameters ===

Revision as of 18:38, 25 October 2018

Heap Memory Profile Probe: hmp.ual

(Since 4.5.0).

The hmp.ual predefined probe profiles the use of heap memory within an application program. The probe records the number, size, and time taken for allocations and deallocations from and to the heap. The profiling information is reported periodically in snapshots and in a final snapshot at the program termination.

Heap profiling allows you to determine how the heap is being used in your application. The heap profile information can be used to locate "hot spots" of heap usage in your application on which to focus your attention when trying to improve your program's performance. This probe focuses on overall usage not on specific allocations and deallocations.

See memstat.ual, memleak.ual and memwatch.ual for other approaches to heap analysis.

Usage

This probe is applied at run time using aprobe as described under Profile UAL Parameters below. Heap profiling data will be collected for the standard memory functions: malloc, calloc, realloc, and free. You would need to modify this probe to collect information from custom allocation functions.

The heap profile information is collected in memory and periodically logged in snapshots logged to the APD file for later processing by apformat. At format time a report is generated for each snapshot and an overall summary for the whole program which details the number and duration of allocations and deallocation of objects of different sizes. The data is tabulated and displayed in histograms. The reports are designed to allow you to identify areas of heavy heap usage based on object sizes rather than specific objects. This analysis may be followed up by custom probes to discover where the application is allocating objects of a specific size, for example.

The default parameters provide good initial coverage of heap object sizes by defining bucket sizes that increase by powers of two. Object smaller than the smallest bucket size are tallied in the the smallest bucket and object larger than the largest bucket size are tallied in the largest bucket. You can focus on specific object size by specifying a starting bucket size and the number of buckets to use with linearly increasing sizes.

Profile UAL Parameters

hmp.ual is specified on the aprobe command line or in an APO file as described in Command Line. The specific options are:

aprobe  -u hmp.ual    [-p "param-list"] your_program

where param_list may include:

-i InitTime
num secs before starting snapshots [SnapTime]
-w WaitTime
wait WaitTime secs before tracking allocations [0]
-s SnapTime
num secs between snapshots after InitTime [30]
-r
reset statistics after each snapshot
-x
collect CPU times in addtion to wall times
-y
Use MONOTONIC clock instead of CPU clock (implies -x)
-b NBuckets
number of buckets : default 16
-c BucketSize
size in bytes of each bucket : default 0 (= doubling)
-d BucketStart
first bucket size in bytes : default 32
-l
track object lifetimes : default off
-t NTimeBuckets
number of time buckets : default 10
-u TimeBucketSize
size in seconds of each time bucket : default 0 (= doubling)
-v TimeBucketStart
first time bucket time in seconds : default 1


Heap Memory Profile API

Users can control the behavior of the heap memory profile probe by calls from within their own probes. The API is defined by [../include/hmp.h $APROBE/include/hmp.h]. The functions exported by hmp.ual are:

ap_Hmp_DoSnapshot

Takes a snapshot of heap memory profile data.

See Snapshots for more information and an example.

Heap Memory Profile Demand Actions

You can control hmp.ual using demand.ual and apdemand.

Include demand.ual on the Aprobe command line:

 aprobe -u hmp -u demand myapp.exe
 

then use apdemand to send actions:

 apdemand hmp snapshot
 

hmp.ual responds to the following actions:

  • hmp snapshot

Note that all actions containing the action string will be triggered.

Heap Memory Profile Performance Issues

See Performance_Issues for a general discussion of factors that affect performance.

You can use the InitTime and WaitTime options to control when heap memory profiling is performed. This can reduce the overhead during application start-up when many tables and other data structures are populated by allocations from the heap.

While snapshots are reasonable quick, you can use the SnapTime option to control how often, if at all, periodic snapshots are taken.

Heap Memory Profile Report

The reports generated by running apformat vary considerably depending upon the options chosen as specified above. The default looks like the example below:

 
 

Example. Heap Memory Profile Probe Output