Index: branches/eam_branches/ipp-20110213/psLib/src/sys/psMemory.c
===================================================================
--- branches/eam_branches/ipp-20110213/psLib/src/sys/psMemory.c	(revision 30716)
+++ branches/eam_branches/ipp-20110213/psLib/src/sys/psMemory.c	(revision 30772)
@@ -27,4 +27,5 @@
 #include <string.h>
 #include <assert.h>
+#include <unistd.h>
 
 #if defined(PS_MEM_BACKTRACE) && defined(HAVE_BACKTRACE)
@@ -1090,2 +1091,34 @@
     return (memBlock1->freeFunc == memBlock2->freeFunc);
 }
+
+bool static dumpMemory = false;
+
+void psMemDumpSetState (bool state) {
+    dumpMemory = state;
+}
+
+void psMemDump(const char *name)
+{
+    if (!dumpMemory) return;
+
+    char filename[1024];	  // don't make your sub-names too long!
+    static int num = 0;		  // Counter, to make files unique and give an idea of sequence
+
+    snprintf (filename, 1024, "memdump_%s_%03d.txt", name, num);
+    FILE *memFile = fopen(filename, "w");
+
+    psMemBlock **leaks = NULL;
+    int numLeaks = psMemCheckLeaks(0, &leaks, NULL, true);
+    fprintf(memFile, "# MemBlock Size Source\n");
+    unsigned long total = 0;            // Total memory used
+    for (int i = 0; i < numLeaks; i++) {
+        psMemBlock *mb = leaks[i];
+        fprintf(memFile, "%12lu\t%12zd\t%s:%d\n", mb->id, mb->userMemorySize, mb->file, mb->lineno);
+        total += mb->userMemorySize;
+    }
+    fclose(memFile);
+    psFree(leaks);
+
+    fprintf(stderr, "Memdump %s %d: Memory use: %ld, sbrk: %p\n", name, num, total, (void *) sbrk(0));
+    num++;
+}
Index: branches/eam_branches/ipp-20110213/psLib/src/sys/psMemory.h
===================================================================
--- branches/eam_branches/ipp-20110213/psLib/src/sys/psMemory.h	(revision 30716)
+++ branches/eam_branches/ipp-20110213/psLib/src/sys/psMemory.h	(revision 30772)
@@ -647,4 +647,7 @@
   );
 
+void psMemDumpSetState (bool state);
+void psMemDump(const char *name);
+
 // Ensure this is a psLib pointer
 #define PS_ASSERT_PTR_HEAVY(PTR, RVAL) \
Index: branches/eam_branches/ipp-20110213/psLib/src/types/psArguments.h
===================================================================
--- branches/eam_branches/ipp-20110213/psLib/src/types/psArguments.h	(revision 30716)
+++ branches/eam_branches/ipp-20110213/psLib/src/types/psArguments.h	(revision 30772)
@@ -81,5 +81,5 @@
  *  specific routine called pkgnameVersionLong() is presumed to exist.
  */
-#define PSARGUMENTS_INSTANTIATE_GENERICS( pkgname, config, argc, argv )   \
+#define PS_ARGUMENTS_GENERIC( pkgname, config, argc, argv )   \
   { int N= psArgumentGet (argc, argv, "-version");                        \
     if (N) {                                                              \
@@ -115,5 +115,5 @@
  *  presumed to exist.
  */
-#define PSARGUMENTS_INSTANTIATE_THREADSARG( pkgname, config, argc, argv )   \
+#define PS_ARGUMENTS_THREADS( pkgname, config, argc, argv )   \
   { int N= psArgumentGet(argc, argv, "-threads");                           \
     if (N) {                                                                \
