3.2. Evaluating Memory Utilization

3.2.1. TAU_TRACK_MEMORY

When TAU_TRACK_MEMORY is called an interrupt is generated every 10 seconds and the memory event is triggered with the current value. This interrupt interval can be changed by calling TAU_SET_INTERRUPT_INTERVAL(value). The tracking of memory events in both cases can be explicitly enabled or disabled by calling the macros TAU_ENABLE_TRACKING_MEMORY() or TAU_DISABLE_TRACKING_MEMORY() respectively.

TAU_TRACK_MEMORY() can be inserted into the source code:

int main(int argc, char **argv)
{
	TAU_PROFILE("main()", " ", TAU_DEFAULT);
	TAU_PROFILE_SET_NODE(0);

	TAU_TRACK_MEMORY();

	sleep(12);

	int *x = new int[5*1024*1024];

	sleep(12);

	return 0;
}

Resulting profile data:

USER EVENTS Profile :NODE 0, CONTEXT 0, THREAD 0
---------------------------------------------------------------------------------------
NumSamples   MaxValue   MinValue  MeanValue  Std. Dev.  Event Name
---------------------------------------------------------------------------------------
         2  2.049E+04      2.891  1.024E+04  1.024E+04  Memory Utilization
			(heap, in KB)
---------------------------------------------------------------------------------------

3.2.2. TAU_TRACK_MEMORY_HERE

Triggers memory tracking at a given execution point. For example:

int main(int argc, char **argv) {
	TAU_PROFILE("main()", " ", TAU_DEFAULT);
	TAU_PROFILE_SET_NODE(0);

	TAU_TRACK_MEMORY_HERE();

	int *x = new int[5*1024*1024];
	TAU_TRACK_MEMORY_HERE();
	return 0;
}

Here is the resulting profile:

USER EVENTS Profile :NODE 0, CONTEXT 0, THREAD 0
---------------------------------------------------------------------------------------
NumSamples   MaxValue   MinValue  MeanValue  Std. Dev.  Event Name
---------------------------------------------------------------------------------------
         2  2.049E+04      2.891  1.024E+04  1.024E+04  Memory Utilization
			(heap, in KB)
---------------------------------------------------------------------------------------