Besides source-level instrumentation, TAU supports pre-processor based replacement of routines. We have implemented a memory tracking package that includes a wrapper library for malloc and free calls in C and C++. By re-directing references to these calls and extracting the source line number and file name, TAU computes the sizes of memory allocated and de-allocated at different locations in the source code. Performance data is stored in atomic user-defined events that track statistics such as the number of samples, maximum, minimum, mean and standard deviation of the memory size. This data helps locate potential memory leaks. Tools such as dmalloc employ similar instrumentation techniques for automated memory leak detection.