Add heap profiler for stmgr
diff --git a/heron/executor/src/python/heron_executor.py b/heron/executor/src/python/heron_executor.py
index e70d388..f7bf667 100755
--- a/heron/executor/src/python/heron_executor.py
+++ b/heron/executor/src/python/heron_executor.py
@@ -720,6 +720,7 @@
   # PEX_ROOT shell environment before forking the processes
   shell_env = os.environ.copy()
   shell_env["PEX_ROOT"] = os.path.join(os.path.abspath('.'), ".pex")
+  shell_env["HEAPPROFILE"] = "stmgr.hprof"
 
   # Instantiate the executor, bind it to signal handlers and launch it
   executor = HeronExecutor(sys.argv, shell_env)
diff --git a/heron/stmgr/src/cpp/BUILD b/heron/stmgr/src/cpp/BUILD
index cda092d..38c1ae3 100644
--- a/heron/stmgr/src/cpp/BUILD
+++ b/heron/stmgr/src/cpp/BUILD
@@ -107,6 +107,7 @@
         "server/stmgr-main.cpp",
     ],
     copts = [
+        "-Ithird_party",
         "-Iheron",
         "-Iheron/common/src/cpp",
         "-Iheron/statemgrs/src/cpp",
@@ -125,6 +126,7 @@
         "//heron/common/src/cpp/metrics:metrics-cxx",
         "//heron/statemgrs/src/cpp:statemgrs-cxx",
         "//third_party/yaml-cpp:yaml-cxx",
+        "//third_party/gperftools:profiler-cxx",
     ],
     linkstatic = 1,
 )
diff --git a/heron/stmgr/src/cpp/server/stmgr-main.cpp b/heron/stmgr/src/cpp/server/stmgr-main.cpp
index 79404b1..4680259 100644
--- a/heron/stmgr/src/cpp/server/stmgr-main.cpp
+++ b/heron/stmgr/src/cpp/server/stmgr-main.cpp
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <gperftools/heap-profiler.h>
 #include <iostream>
 #include <string>
 #include <vector>
@@ -54,6 +55,8 @@
   sp_int32 shell_port = atoi(argv[10]);
   sp_string heron_internals_config_filename = argv[11];
 
+  HeapProfilerStart("stmgr");
+
   EventLoopImpl ss;
 
   // Read heron internals config from local file
@@ -74,5 +77,6 @@
                           zkhostportlist, topdir, metricsmgr_port, shell_port);
   mgr.Init();
   ss.loop();
+  HeapProfilerStop();
   return 0;
 }
diff --git a/third_party/gperftools/BUILD b/third_party/gperftools/BUILD
index 195b2e2..5161b76 100644
--- a/third_party/gperftools/BUILD
+++ b/third_party/gperftools/BUILD
@@ -100,6 +100,7 @@
         "lib/libprofiler.a",
     ],
     hdrs = [
+        "include/gperftools/heap-profiler.h",
         "include/gperftools/profiler.h",
     ],
     includes = ["include"],