Index: src/Common/Stats/Heap.cc
===================================================================
--- src/Common/Stats/Heap.cc	(revision 095b99a642c9068d6d432af63ad1a7e1b7fb9ec2)
+++ src/Common/Stats/Heap.cc	(revision 31a6f38ca7d2e1a23150072813a3cdf4f57f44f6)
@@ -53,4 +53,28 @@
 		const size_t passes_size = sizeof(passes) / sizeof(passes[0]);
 		size_t       passes_cnt = 1;
+
+		StatBlock    stacktrace_stats[100];
+		size_t       stacktrace_stats_count = 0;
+		bool         stacktrace_stats_enabled = true;
+
+		size_t       trace[1000];
+		const size_t stacktrace_max_depth = sizeof(trace) / sizeof(size_t);
+		size_t       stacktrace_depth;
+
+		size_t new_stacktrace_id(const char * const name) {
+			stacktrace_stats[stacktrace_stats_count].name = name;
+			return stacktrace_stats_count++;
+		}
+
+		void stacktrace_push(size_t id) {
+			++stacktrace_depth;
+			assertf(stacktrace_depth < stacktrace_max_depth, "Stack trace too deep: increase size of array in Heap.cc");
+			trace[stacktrace_depth] = id;
+		}
+
+		void stacktrace_pop() {
+			assertf(stacktrace_depth > 0, "Invalid stack tracing operation: trace is empty");
+			--stacktrace_depth;
+		}
 
 		void newPass( const char * const name ) {
@@ -116,4 +140,13 @@
 			for(size_t i = 0; i < passes_cnt; i++) {
 				print(passes[i], nc, total_mallocs, total_frees, overall_peak);
+			}
+
+			print('-', nct);
+			std::cerr << std::setw(nc) << "Trace";
+			std::cerr << " |       Malloc Count |         Free Count |        Peak Allocs |" << std::endl;
+
+			print('-', nct);
+			for (size_t i = 0; i < stacktrace_stats_count; i++) {
+				print(stacktrace_stats[i], nc, total_mallocs, total_frees, overall_peak);
 			}
 			print('-', nct);
@@ -188,4 +221,8 @@
 						= std::max(passes[passes_cnt - 1].peak_allocs, passes[passes_cnt - 1].n_allocs);
 				}
+
+				if ( stacktrace_stats_enabled && stacktrace_depth > 0) {
+					stacktrace_stats[trace[stacktrace_depth]].mallocs++;
+				}
 				return __malloc( size );
 			}
@@ -196,4 +233,7 @@
 					passes[passes_cnt - 1].frees++;
 					passes[passes_cnt - 1].n_allocs--;
+				}
+				if ( stacktrace_stats_enabled && stacktrace_depth > 0) {
+					stacktrace_stats[trace[stacktrace_depth]].frees++;
 				}
 				return __free( ptr );
@@ -208,4 +248,7 @@
 						= std::max(passes[passes_cnt - 1].peak_allocs, passes[passes_cnt - 1].n_allocs);
 				}
+				if ( stacktrace_stats_enabled && stacktrace_depth > 0) {
+					stacktrace_stats[trace[stacktrace_depth]].mallocs++;
+				}
 				return __calloc( nelem, size );
 			}
@@ -218,4 +261,8 @@
 					passes[passes_cnt - 1].frees++;
 				} // if
+				if ( stacktrace_stats_enabled && stacktrace_depth > 0) {
+					stacktrace_stats[trace[stacktrace_depth]].mallocs++;
+					stacktrace_stats[trace[stacktrace_depth]].frees++;
+				}
 				return s;
 			}
Index: src/Common/Stats/Heap.h
===================================================================
--- src/Common/Stats/Heap.h	(revision 095b99a642c9068d6d432af63ad1a7e1b7fb9ec2)
+++ src/Common/Stats/Heap.h	(revision 31a6f38ca7d2e1a23150072813a3cdf4f57f44f6)
@@ -20,4 +20,8 @@
 		void newPass( const char * const name );
 		void print();
+
+		size_t new_stacktrace_id(const char * const name);
+		void stacktrace_push(size_t id);
+		void stacktrace_pop();
 	}
 }
