Index: /trunk/psLib/src/sys/psError.c
===================================================================
--- /trunk/psLib/src/sys/psError.c	(revision 1809)
+++ /trunk/psLib/src/sys/psError.c	(revision 1810)
@@ -10,6 +10,6 @@
  *  @author Eric Van Alst, MHPCC
  *   
- *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-14 20:01:52 $
+ *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-14 23:48:25 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -40,4 +40,7 @@
         errorStack[errorStackSize] = psMemIncrRefCounter(err);
         errorStackSize++;
+        p_psMemSetPersistent(err,true);
+        p_psMemSetPersistent(err->msg,true);
+        p_psMemSetPersistent(err->name,true);
     }
 
@@ -83,4 +86,7 @@
     pthread_mutex_lock(&lockErrorStack);
     for (int lcv=0;lcv<errorStackSize;lcv++) {
+        p_psMemSetPersistent(errorStack[lcv]->msg,false);
+        p_psMemSetPersistent(errorStack[lcv]->name,false);
+        p_psMemSetPersistent(errorStack[lcv],false);
         psFree(errorStack[lcv]);
     }
Index: /trunk/psLib/src/sys/psMemory.c
===================================================================
--- /trunk/psLib/src/sys/psMemory.c	(revision 1809)
+++ /trunk/psLib/src/sys/psMemory.c	(revision 1810)
@@ -1,3 +1,2 @@
-
 /** @file  psMemory.c
 *
@@ -9,6 +8,6 @@
 *  @author Robert Lupton, Princeton University
 *
-*  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-09-08 21:06:00 $
+*  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-09-14 23:48:25 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -341,4 +340,5 @@
     ptr->file = file;
     ptr->freeFcn = NULL;
+    ptr->persistent = false;
     *(unsigned int *)&ptr->lineno = lineno;
     *(void **)((int8_t *) (ptr + 1) + size) = P_PS_MEMMAGIC;
@@ -446,5 +446,8 @@
 
     for (psMemBlock* iter = topBlock; iter != NULL; iter = iter->nextBlock) {
-        if ((psMemGetRefCounter(iter + 1) > 0) && (iter->id >= id0)) {
+        if ( (iter->refCounter > 0) &&
+                (! iter->persistent) &&
+                (iter->id >= id0)) {
+
             nleak++;
 
@@ -469,5 +472,8 @@
 
     for (psMemBlock* iter = topBlock; iter != NULL; iter = iter->nextBlock) {
-        if ((psMemGetRefCounter(iter + 1) > 0) && (iter->id >= id0)) {
+        if ( (iter->refCounter > 0) &&
+                (! iter->persistent) &&
+                (iter->id >= id0)) {
+
             (*arr)[j++] = iter;
             if (j == nleak) {              // found them all
@@ -651,2 +657,32 @@
     return ptr->freeFcn;
 }
+
+bool p_psMemGetPersistent(void *vptr)
+{
+    if (vptr == NULL) {
+        return NULL;
+    }
+
+    psMemBlock* ptr = ((psMemBlock* ) vptr) - 1;
+
+    if (checkMemBlock(ptr, __func__) != 0) {
+        memProblemCallback(ptr, __func__, __LINE__);
+    }
+
+    return ptr->persistent;
+}
+
+void p_psMemSetPersistent(void *vptr,bool value)
+{
+    if (vptr == NULL) {
+        return;
+    }
+
+    psMemBlock* ptr = ((psMemBlock* ) vptr) - 1;
+
+    if (checkMemBlock(ptr, __func__) != 0) {
+        memProblemCallback(ptr, __func__, __LINE__);
+    }
+
+    ptr->persistent = value;
+}
Index: /trunk/psLib/src/sys/psMemory.h
===================================================================
--- /trunk/psLib/src/sys/psMemory.h	(revision 1809)
+++ /trunk/psLib/src/sys/psMemory.h	(revision 1810)
@@ -12,6 +12,6 @@
  *  @ingroup MemoryManagement
  *
- *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-08-23 22:36:03 $
+ *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-14 23:48:25 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -73,4 +73,5 @@
     pthread_mutex_t refCounterMutex;   ///< mutex to ensure exclusive access to reference counter
     psReferenceCount refCounter;       ///< how many times pointer is referenced
+    bool persistent;                   ///< marks if this non-user persistent data like error stack, etc.
     const void *endblock;              ///< initialised to p_psMEMMAGIC
 }
@@ -163,4 +164,33 @@
     void *ptr                          ///< the memory block
 );
+
+/** Set the memory as persistent so that it is ignored when detecting memory leaks.
+ *
+ *  Used to mark a memory block as persistent data within the library, 
+ *  i.e., non user-level data used to hold psLib's state or cache data.  Such
+ *  examples of this class of memory is psTrace's trace-levels and dynamic
+ *  error codes.
+ *
+ *  Memory marked as persistent is excluded from memory leak checks.
+ *
+ */
+void p_psMemSetPersistent(
+    void *ptr,                         ///< the memory block to operate on
+    bool value                         ///< true if memory is persistent, otherwise false
+);
+
+/** Get the memory's persistent flag.
+ *
+ *  Checks if a memory block has been marked as persistent by 
+ *  p_psMemSetPresistent.
+ *
+ *  Memory marked as persistent is excluded from memory leak checks.
+ *
+ *  @return bool    true if memory is marked persistent, otherwise false.
+ */
+bool p_psMemGetPersistent(
+    void *ptr                          ///< the memory block to check.
+);
+
 
 /** Memory re-allocation.  This operates much like realloc(), but is guaranteed to return a non-NULL value.
Index: /trunk/psLib/src/sys/psTrace.c
===================================================================
--- /trunk/psLib/src/sys/psTrace.c	(revision 1809)
+++ /trunk/psLib/src/sys/psTrace.c	(revision 1810)
@@ -9,6 +9,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-09 01:46:15 $
+ *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-14 23:48:25 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -65,6 +65,8 @@
     p_psComponent* comp = psAlloc(sizeof(p_psComponent));
 
+    p_psMemSetPersistent(comp,true);
     p_psMemSetDeallocator(comp, (psFreeFcn) componentFree);
     comp->name = psStringCopy(name);
+    p_psMemSetPersistent((void*)comp->name,true);
     comp->level = level;
     comp->n = 0;
@@ -85,10 +87,13 @@
     if (comp->subcomp != NULL) {
         for (int i = 0; i < comp->n; i++) {
+            p_psMemSetPersistent(comp->subcomp[i],false);
             psFree(comp->subcomp[i]);
         }
+        p_psMemSetPersistent(comp->subcomp,false);
         psFree(comp->subcomp);
     }
 
-    psFree((char *)comp->name);
+    p_psMemSetPersistent((void*)comp->name,false);
+    psFree((void*)comp->name);
 }
 
@@ -195,4 +200,6 @@
             currentNode->subcomp = psRealloc(currentNode->subcomp,
                                              (currentNode->n + 1) * sizeof(p_psComponent* ));
+            p_psMemSetPersistent(currentNode->subcomp,true);
+
             currentNode->n = (currentNode->n) + 1;
 
Index: /trunk/psLib/src/sysUtils/psError.c
===================================================================
--- /trunk/psLib/src/sysUtils/psError.c	(revision 1809)
+++ /trunk/psLib/src/sysUtils/psError.c	(revision 1810)
@@ -10,6 +10,6 @@
  *  @author Eric Van Alst, MHPCC
  *   
- *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-14 20:01:52 $
+ *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-14 23:48:25 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -40,4 +40,7 @@
         errorStack[errorStackSize] = psMemIncrRefCounter(err);
         errorStackSize++;
+        p_psMemSetPersistent(err,true);
+        p_psMemSetPersistent(err->msg,true);
+        p_psMemSetPersistent(err->name,true);
     }
 
@@ -83,4 +86,7 @@
     pthread_mutex_lock(&lockErrorStack);
     for (int lcv=0;lcv<errorStackSize;lcv++) {
+        p_psMemSetPersistent(errorStack[lcv]->msg,false);
+        p_psMemSetPersistent(errorStack[lcv]->name,false);
+        p_psMemSetPersistent(errorStack[lcv],false);
         psFree(errorStack[lcv]);
     }
Index: /trunk/psLib/src/sysUtils/psMemory.c
===================================================================
--- /trunk/psLib/src/sysUtils/psMemory.c	(revision 1809)
+++ /trunk/psLib/src/sysUtils/psMemory.c	(revision 1810)
@@ -1,3 +1,2 @@
-
 /** @file  psMemory.c
 *
@@ -9,6 +8,6 @@
 *  @author Robert Lupton, Princeton University
 *
-*  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-09-08 21:06:00 $
+*  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-09-14 23:48:25 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -341,4 +340,5 @@
     ptr->file = file;
     ptr->freeFcn = NULL;
+    ptr->persistent = false;
     *(unsigned int *)&ptr->lineno = lineno;
     *(void **)((int8_t *) (ptr + 1) + size) = P_PS_MEMMAGIC;
@@ -446,5 +446,8 @@
 
     for (psMemBlock* iter = topBlock; iter != NULL; iter = iter->nextBlock) {
-        if ((psMemGetRefCounter(iter + 1) > 0) && (iter->id >= id0)) {
+        if ( (iter->refCounter > 0) &&
+                (! iter->persistent) &&
+                (iter->id >= id0)) {
+
             nleak++;
 
@@ -469,5 +472,8 @@
 
     for (psMemBlock* iter = topBlock; iter != NULL; iter = iter->nextBlock) {
-        if ((psMemGetRefCounter(iter + 1) > 0) && (iter->id >= id0)) {
+        if ( (iter->refCounter > 0) &&
+                (! iter->persistent) &&
+                (iter->id >= id0)) {
+
             (*arr)[j++] = iter;
             if (j == nleak) {              // found them all
@@ -651,2 +657,32 @@
     return ptr->freeFcn;
 }
+
+bool p_psMemGetPersistent(void *vptr)
+{
+    if (vptr == NULL) {
+        return NULL;
+    }
+
+    psMemBlock* ptr = ((psMemBlock* ) vptr) - 1;
+
+    if (checkMemBlock(ptr, __func__) != 0) {
+        memProblemCallback(ptr, __func__, __LINE__);
+    }
+
+    return ptr->persistent;
+}
+
+void p_psMemSetPersistent(void *vptr,bool value)
+{
+    if (vptr == NULL) {
+        return;
+    }
+
+    psMemBlock* ptr = ((psMemBlock* ) vptr) - 1;
+
+    if (checkMemBlock(ptr, __func__) != 0) {
+        memProblemCallback(ptr, __func__, __LINE__);
+    }
+
+    ptr->persistent = value;
+}
Index: /trunk/psLib/src/sysUtils/psMemory.h
===================================================================
--- /trunk/psLib/src/sysUtils/psMemory.h	(revision 1809)
+++ /trunk/psLib/src/sysUtils/psMemory.h	(revision 1810)
@@ -12,6 +12,6 @@
  *  @ingroup MemoryManagement
  *
- *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-08-23 22:36:03 $
+ *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-14 23:48:25 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -73,4 +73,5 @@
     pthread_mutex_t refCounterMutex;   ///< mutex to ensure exclusive access to reference counter
     psReferenceCount refCounter;       ///< how many times pointer is referenced
+    bool persistent;                   ///< marks if this non-user persistent data like error stack, etc.
     const void *endblock;              ///< initialised to p_psMEMMAGIC
 }
@@ -163,4 +164,33 @@
     void *ptr                          ///< the memory block
 );
+
+/** Set the memory as persistent so that it is ignored when detecting memory leaks.
+ *
+ *  Used to mark a memory block as persistent data within the library, 
+ *  i.e., non user-level data used to hold psLib's state or cache data.  Such
+ *  examples of this class of memory is psTrace's trace-levels and dynamic
+ *  error codes.
+ *
+ *  Memory marked as persistent is excluded from memory leak checks.
+ *
+ */
+void p_psMemSetPersistent(
+    void *ptr,                         ///< the memory block to operate on
+    bool value                         ///< true if memory is persistent, otherwise false
+);
+
+/** Get the memory's persistent flag.
+ *
+ *  Checks if a memory block has been marked as persistent by 
+ *  p_psMemSetPresistent.
+ *
+ *  Memory marked as persistent is excluded from memory leak checks.
+ *
+ *  @return bool    true if memory is marked persistent, otherwise false.
+ */
+bool p_psMemGetPersistent(
+    void *ptr                          ///< the memory block to check.
+);
+
 
 /** Memory re-allocation.  This operates much like realloc(), but is guaranteed to return a non-NULL value.
Index: /trunk/psLib/src/sysUtils/psTrace.c
===================================================================
--- /trunk/psLib/src/sysUtils/psTrace.c	(revision 1809)
+++ /trunk/psLib/src/sysUtils/psTrace.c	(revision 1810)
@@ -9,6 +9,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-09 01:46:15 $
+ *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-14 23:48:25 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -65,6 +65,8 @@
     p_psComponent* comp = psAlloc(sizeof(p_psComponent));
 
+    p_psMemSetPersistent(comp,true);
     p_psMemSetDeallocator(comp, (psFreeFcn) componentFree);
     comp->name = psStringCopy(name);
+    p_psMemSetPersistent((void*)comp->name,true);
     comp->level = level;
     comp->n = 0;
@@ -85,10 +87,13 @@
     if (comp->subcomp != NULL) {
         for (int i = 0; i < comp->n; i++) {
+            p_psMemSetPersistent(comp->subcomp[i],false);
             psFree(comp->subcomp[i]);
         }
+        p_psMemSetPersistent(comp->subcomp,false);
         psFree(comp->subcomp);
     }
 
-    psFree((char *)comp->name);
+    p_psMemSetPersistent((void*)comp->name,false);
+    psFree((void*)comp->name);
 }
 
@@ -195,4 +200,6 @@
             currentNode->subcomp = psRealloc(currentNode->subcomp,
                                              (currentNode->n + 1) * sizeof(p_psComponent* ));
+            p_psMemSetPersistent(currentNode->subcomp,true);
+
             currentNode->n = (currentNode->n) + 1;
 
Index: /trunk/psLib/test/dataManip/tst_psFunc00.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psFunc00.c	(revision 1809)
+++ /trunk/psLib/test/dataManip/tst_psFunc00.c	(revision 1810)
@@ -237,5 +237,5 @@
 
     psFree(my3DPolyD);
-    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
     if (0 != memLeaks) {
         psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
@@ -271,5 +271,5 @@
 
     psFree(my4DPolyD);
-    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
     if (0 != memLeaks) {
         psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
@@ -301,5 +301,5 @@
 
     psFree(my1DPoly);
-    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
     if (0 != memLeaks) {
         psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
@@ -330,5 +330,5 @@
 
     psFree(my2DPoly);
-    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
     if (0 != memLeaks) {
         psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
@@ -361,5 +361,5 @@
 
     psFree(my3DPoly);
-    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
     if (0 != memLeaks) {
         psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
@@ -395,5 +395,5 @@
 
     psFree(my4DPoly);
-    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
     if (0 != memLeaks) {
         psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
@@ -425,5 +425,5 @@
 
     psFree(my1DPolyD);
-    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
     if (0 != memLeaks) {
         psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
@@ -451,5 +451,5 @@
 
     psFree(my2DPolyD);
-    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
     if (0 != memLeaks) {
         psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
@@ -482,5 +482,5 @@
 
     psFree(my3DPolyD);
-    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
     if (0 != memLeaks) {
         psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
@@ -516,5 +516,5 @@
 
     psFree(my4DPolyD);
-    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
     if (0 != memLeaks) {
         psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
Index: /trunk/psLib/test/dataManip/tst_psMinimize05.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psMinimize05.c	(revision 1809)
+++ /trunk/psLib/test/dataManip/tst_psMinimize05.c	(revision 1810)
@@ -99,5 +99,5 @@
 
     psMemCheckCorruption(1);
-    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
     if (0 != memLeaks) {
         psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
Index: /trunk/psLib/test/dataManip/tst_psStats07.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psStats07.c	(revision 1809)
+++ /trunk/psLib/test/dataManip/tst_psStats07.c	(revision 1810)
@@ -402,5 +402,5 @@
 
     psMemCheckCorruption( 1 );
-    memLeaks = psMemCheckLeaks( currentId, NULL, NULL );
+    memLeaks = psMemCheckLeaks( currentId, NULL, stderr );
     if ( 0 != memLeaks ) {
         psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks );
Index: /trunk/psLib/test/psTest.c
===================================================================
--- /trunk/psLib/test/psTest.c	(revision 1809)
+++ /trunk/psLib/test/psTest.c	(revision 1810)
@@ -149,6 +149,4 @@
             int currentId = psMemGetId();
             int retVal = fcn();
-            psErrorClear(); // clear the error stack before checking for leaks
-            psTraceReset();
             if ( retVal == 0 ) { // only bother checking memory if test executed to end.
                 if ( psMemCheckLeaks( currentId, NULL, stderr ) != 0 ) {
@@ -175,6 +173,4 @@
         int currentId = psMemGetId();
         childReturn = fcn();
-        psErrorClear(); // clear the error stack before checking for leaks
-        psTraceReset();
         if ( childReturn == 0 ) { // only bother checking memory if test executed to end.
             if ( psMemCheckLeaks( currentId, NULL, stderr ) != 0 ) {
