From fbe29a4595e970eb2c5069afc713cecb785948d7 Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Thu, 16 Jun 2011 10:54:52 -0700
Subject: [PATCH] Improve memory leak testing documentation

---
 BUILD.NOTES                | 14 +++++++++++---
 src/slurmctld/controller.c |  4 ++--
 src/slurmd/slurmd/slurmd.c |  4 ++--
 3 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/BUILD.NOTES b/BUILD.NOTES
index cf59b3e0e73..6bcf38fc0c4 100644
--- a/BUILD.NOTES
+++ b/BUILD.NOTES
@@ -226,9 +226,17 @@ not change gnats bug state, but records source files associated
 with the bug.
 
 For memory leaks (for AIX use zerofault, zf; for linux use valgrind)
- - run configure with the option --enable-memory-leak-debug
- - valgrind --tool=memcheck --leak-check=yes --num-callers=6 --leak-resolution=med \
-   ./slurmctld -Dc >ctld.out 2>&1    (or similar like for slurmd)
+ - Run configure with the option "--enable-memory-leak-debug" to completely
+   release allocated memory when the daemons exit
+ - valgrind --tool=memcheck --leak-check=yes --num-callers=8 --leak-resolution=med \
+   ./slurmctld -Dc >valg.ctld.out 2>&1
+ - valgrind --tool=memcheck --leak-check=yes --num-callers=8 --leak-resolution=med \
+   ./slurmd -Dc >valg.slurmd.out 2>&1    (Probably only one one node of cluster)
+ - Run the regression test. In the globals.local file include:
+   "set enable_memory_leak_debug 1"
+ - Shutdown the daemons using "scontrol shutdown"
+ - Examine the end of the log files for leaks. pthread_create() and dlopen()
+   have small memory leaks on some systems, which do not grow over time
 
 Before new major release:
  - Test on ia64, i386, x86_64, BGL, AIX, OSX, XCPU
diff --git a/src/slurmctld/controller.c b/src/slurmctld/controller.c
index 898ab8450b7..dd7a1a2ca70 100644
--- a/src/slurmctld/controller.c
+++ b/src/slurmctld/controller.c
@@ -125,8 +125,8 @@
 /**************************************************************************\
  * To test for memory leaks, set MEMORY_LEAK_DEBUG to 1 using
  * "configure --enable-memory-leak-debug" then execute
- * > valgrind --tool=memcheck --leak-check=yes --num-callers=6 \
- *    --leak-resolution=med slurmctld -D
+ * $ valgrind --tool=memcheck --leak-check=yes --num-callers=8 \
+ *   --leak-resolution=med ./slurmctld -Dc >valg.ctld.out 2>&1
  *
  * Then exercise the slurmctld functionality before executing
  * > scontrol shutdown
diff --git a/src/slurmd/slurmd/slurmd.c b/src/slurmd/slurmd/slurmd.c
index 3db54308478..8791dcbd719 100644
--- a/src/slurmd/slurmd/slurmd.c
+++ b/src/slurmd/slurmd/slurmd.c
@@ -1378,8 +1378,8 @@ cleanup:
 /**************************************************************************\
  * To test for memory leaks, set MEMORY_LEAK_DEBUG to 1 using
  * "configure --enable-memory-leak-debug" then execute
- * > valgrind --tool=memcheck --leak-check=yes --num-callers=6
- *    --leak-resolution=med slurmd -D
+ * $ valgrind --tool=memcheck --leak-check=yes --num-callers=8 \
+ *   --leak-resolution=med ./slurmd -Dc >valg.slurmd.out 2>&1
  *
  * Then exercise the slurmd functionality before executing
  * > scontrol shutdown
-- 
GitLab