IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1810


Ignore:
Timestamp:
Sep 14, 2004, 1:48:25 PM (22 years ago)
Author:
desonia
Message:

adjustments to coorespond to adding persistent flag to psMemBlock, i.e.,
exclusion of internal library blocks in memory leak checks.

Location:
trunk/psLib
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/sys/psError.c

    r1807 r1810  
    1010 *  @author Eric Van Alst, MHPCC
    1111 *   
    12  *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-09-14 20:01:52 $
     12 *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-09-14 23:48:25 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4040        errorStack[errorStackSize] = psMemIncrRefCounter(err);
    4141        errorStackSize++;
     42        p_psMemSetPersistent(err,true);
     43        p_psMemSetPersistent(err->msg,true);
     44        p_psMemSetPersistent(err->name,true);
    4245    }
    4346
     
    8386    pthread_mutex_lock(&lockErrorStack);
    8487    for (int lcv=0;lcv<errorStackSize;lcv++) {
     88        p_psMemSetPersistent(errorStack[lcv]->msg,false);
     89        p_psMemSetPersistent(errorStack[lcv]->name,false);
     90        p_psMemSetPersistent(errorStack[lcv],false);
    8591        psFree(errorStack[lcv]);
    8692    }
  • trunk/psLib/src/sys/psMemory.c

    r1730 r1810  
    1 
    21/** @file  psMemory.c
    32*
     
    98*  @author Robert Lupton, Princeton University
    109*
    11 *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2004-09-08 21:06:00 $
     10*  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2004-09-14 23:48:25 $
    1312*
    1413*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    341340    ptr->file = file;
    342341    ptr->freeFcn = NULL;
     342    ptr->persistent = false;
    343343    *(unsigned int *)&ptr->lineno = lineno;
    344344    *(void **)((int8_t *) (ptr + 1) + size) = P_PS_MEMMAGIC;
     
    446446
    447447    for (psMemBlock* iter = topBlock; iter != NULL; iter = iter->nextBlock) {
    448         if ((psMemGetRefCounter(iter + 1) > 0) && (iter->id >= id0)) {
     448        if ( (iter->refCounter > 0) &&
     449                (! iter->persistent) &&
     450                (iter->id >= id0)) {
     451
    449452            nleak++;
    450453
     
    469472
    470473    for (psMemBlock* iter = topBlock; iter != NULL; iter = iter->nextBlock) {
    471         if ((psMemGetRefCounter(iter + 1) > 0) && (iter->id >= id0)) {
     474        if ( (iter->refCounter > 0) &&
     475                (! iter->persistent) &&
     476                (iter->id >= id0)) {
     477
    472478            (*arr)[j++] = iter;
    473479            if (j == nleak) {              // found them all
     
    651657    return ptr->freeFcn;
    652658}
     659
     660bool p_psMemGetPersistent(void *vptr)
     661{
     662    if (vptr == NULL) {
     663        return NULL;
     664    }
     665
     666    psMemBlock* ptr = ((psMemBlock* ) vptr) - 1;
     667
     668    if (checkMemBlock(ptr, __func__) != 0) {
     669        memProblemCallback(ptr, __func__, __LINE__);
     670    }
     671
     672    return ptr->persistent;
     673}
     674
     675void p_psMemSetPersistent(void *vptr,bool value)
     676{
     677    if (vptr == NULL) {
     678        return;
     679    }
     680
     681    psMemBlock* ptr = ((psMemBlock* ) vptr) - 1;
     682
     683    if (checkMemBlock(ptr, __func__) != 0) {
     684        memProblemCallback(ptr, __func__, __LINE__);
     685    }
     686
     687    ptr->persistent = value;
     688}
  • trunk/psLib/src/sys/psMemory.h

    r1606 r1810  
    1212 *  @ingroup MemoryManagement
    1313 *
    14  *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2004-08-23 22:36:03 $
     14 *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2004-09-14 23:48:25 $
    1616 *
    1717 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7373    pthread_mutex_t refCounterMutex;   ///< mutex to ensure exclusive access to reference counter
    7474    psReferenceCount refCounter;       ///< how many times pointer is referenced
     75    bool persistent;                   ///< marks if this non-user persistent data like error stack, etc.
    7576    const void *endblock;              ///< initialised to p_psMEMMAGIC
    7677}
     
    163164    void *ptr                          ///< the memory block
    164165);
     166
     167/** Set the memory as persistent so that it is ignored when detecting memory leaks.
     168 *
     169 *  Used to mark a memory block as persistent data within the library,
     170 *  i.e., non user-level data used to hold psLib's state or cache data.  Such
     171 *  examples of this class of memory is psTrace's trace-levels and dynamic
     172 *  error codes.
     173 *
     174 *  Memory marked as persistent is excluded from memory leak checks.
     175 *
     176 */
     177void p_psMemSetPersistent(
     178    void *ptr,                         ///< the memory block to operate on
     179    bool value                         ///< true if memory is persistent, otherwise false
     180);
     181
     182/** Get the memory's persistent flag.
     183 *
     184 *  Checks if a memory block has been marked as persistent by
     185 *  p_psMemSetPresistent.
     186 *
     187 *  Memory marked as persistent is excluded from memory leak checks.
     188 *
     189 *  @return bool    true if memory is marked persistent, otherwise false.
     190 */
     191bool p_psMemGetPersistent(
     192    void *ptr                          ///< the memory block to check.
     193);
     194
    165195
    166196/** Memory re-allocation.  This operates much like realloc(), but is guaranteed to return a non-NULL value.
  • trunk/psLib/src/sys/psTrace.c

    r1744 r1810  
    99 *  @author George Gusciora, MHPCC
    1010 *
    11  *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-09-09 01:46:15 $
     11 *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-09-14 23:48:25 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6565    p_psComponent* comp = psAlloc(sizeof(p_psComponent));
    6666
     67    p_psMemSetPersistent(comp,true);
    6768    p_psMemSetDeallocator(comp, (psFreeFcn) componentFree);
    6869    comp->name = psStringCopy(name);
     70    p_psMemSetPersistent((void*)comp->name,true);
    6971    comp->level = level;
    7072    comp->n = 0;
     
    8587    if (comp->subcomp != NULL) {
    8688        for (int i = 0; i < comp->n; i++) {
     89            p_psMemSetPersistent(comp->subcomp[i],false);
    8790            psFree(comp->subcomp[i]);
    8891        }
     92        p_psMemSetPersistent(comp->subcomp,false);
    8993        psFree(comp->subcomp);
    9094    }
    9195
    92     psFree((char *)comp->name);
     96    p_psMemSetPersistent((void*)comp->name,false);
     97    psFree((void*)comp->name);
    9398}
    9499
     
    195200            currentNode->subcomp = psRealloc(currentNode->subcomp,
    196201                                             (currentNode->n + 1) * sizeof(p_psComponent* ));
     202            p_psMemSetPersistent(currentNode->subcomp,true);
     203
    197204            currentNode->n = (currentNode->n) + 1;
    198205
  • trunk/psLib/src/sysUtils/psError.c

    r1807 r1810  
    1010 *  @author Eric Van Alst, MHPCC
    1111 *   
    12  *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-09-14 20:01:52 $
     12 *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-09-14 23:48:25 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4040        errorStack[errorStackSize] = psMemIncrRefCounter(err);
    4141        errorStackSize++;
     42        p_psMemSetPersistent(err,true);
     43        p_psMemSetPersistent(err->msg,true);
     44        p_psMemSetPersistent(err->name,true);
    4245    }
    4346
     
    8386    pthread_mutex_lock(&lockErrorStack);
    8487    for (int lcv=0;lcv<errorStackSize;lcv++) {
     88        p_psMemSetPersistent(errorStack[lcv]->msg,false);
     89        p_psMemSetPersistent(errorStack[lcv]->name,false);
     90        p_psMemSetPersistent(errorStack[lcv],false);
    8591        psFree(errorStack[lcv]);
    8692    }
  • trunk/psLib/src/sysUtils/psMemory.c

    r1730 r1810  
    1 
    21/** @file  psMemory.c
    32*
     
    98*  @author Robert Lupton, Princeton University
    109*
    11 *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2004-09-08 21:06:00 $
     10*  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2004-09-14 23:48:25 $
    1312*
    1413*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    341340    ptr->file = file;
    342341    ptr->freeFcn = NULL;
     342    ptr->persistent = false;
    343343    *(unsigned int *)&ptr->lineno = lineno;
    344344    *(void **)((int8_t *) (ptr + 1) + size) = P_PS_MEMMAGIC;
     
    446446
    447447    for (psMemBlock* iter = topBlock; iter != NULL; iter = iter->nextBlock) {
    448         if ((psMemGetRefCounter(iter + 1) > 0) && (iter->id >= id0)) {
     448        if ( (iter->refCounter > 0) &&
     449                (! iter->persistent) &&
     450                (iter->id >= id0)) {
     451
    449452            nleak++;
    450453
     
    469472
    470473    for (psMemBlock* iter = topBlock; iter != NULL; iter = iter->nextBlock) {
    471         if ((psMemGetRefCounter(iter + 1) > 0) && (iter->id >= id0)) {
     474        if ( (iter->refCounter > 0) &&
     475                (! iter->persistent) &&
     476                (iter->id >= id0)) {
     477
    472478            (*arr)[j++] = iter;
    473479            if (j == nleak) {              // found them all
     
    651657    return ptr->freeFcn;
    652658}
     659
     660bool p_psMemGetPersistent(void *vptr)
     661{
     662    if (vptr == NULL) {
     663        return NULL;
     664    }
     665
     666    psMemBlock* ptr = ((psMemBlock* ) vptr) - 1;
     667
     668    if (checkMemBlock(ptr, __func__) != 0) {
     669        memProblemCallback(ptr, __func__, __LINE__);
     670    }
     671
     672    return ptr->persistent;
     673}
     674
     675void p_psMemSetPersistent(void *vptr,bool value)
     676{
     677    if (vptr == NULL) {
     678        return;
     679    }
     680
     681    psMemBlock* ptr = ((psMemBlock* ) vptr) - 1;
     682
     683    if (checkMemBlock(ptr, __func__) != 0) {
     684        memProblemCallback(ptr, __func__, __LINE__);
     685    }
     686
     687    ptr->persistent = value;
     688}
  • trunk/psLib/src/sysUtils/psMemory.h

    r1606 r1810  
    1212 *  @ingroup MemoryManagement
    1313 *
    14  *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2004-08-23 22:36:03 $
     14 *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2004-09-14 23:48:25 $
    1616 *
    1717 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7373    pthread_mutex_t refCounterMutex;   ///< mutex to ensure exclusive access to reference counter
    7474    psReferenceCount refCounter;       ///< how many times pointer is referenced
     75    bool persistent;                   ///< marks if this non-user persistent data like error stack, etc.
    7576    const void *endblock;              ///< initialised to p_psMEMMAGIC
    7677}
     
    163164    void *ptr                          ///< the memory block
    164165);
     166
     167/** Set the memory as persistent so that it is ignored when detecting memory leaks.
     168 *
     169 *  Used to mark a memory block as persistent data within the library,
     170 *  i.e., non user-level data used to hold psLib's state or cache data.  Such
     171 *  examples of this class of memory is psTrace's trace-levels and dynamic
     172 *  error codes.
     173 *
     174 *  Memory marked as persistent is excluded from memory leak checks.
     175 *
     176 */
     177void p_psMemSetPersistent(
     178    void *ptr,                         ///< the memory block to operate on
     179    bool value                         ///< true if memory is persistent, otherwise false
     180);
     181
     182/** Get the memory's persistent flag.
     183 *
     184 *  Checks if a memory block has been marked as persistent by
     185 *  p_psMemSetPresistent.
     186 *
     187 *  Memory marked as persistent is excluded from memory leak checks.
     188 *
     189 *  @return bool    true if memory is marked persistent, otherwise false.
     190 */
     191bool p_psMemGetPersistent(
     192    void *ptr                          ///< the memory block to check.
     193);
     194
    165195
    166196/** Memory re-allocation.  This operates much like realloc(), but is guaranteed to return a non-NULL value.
  • trunk/psLib/src/sysUtils/psTrace.c

    r1745 r1810  
    99 *  @author George Gusciora, MHPCC
    1010 *
    11  *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-09-09 01:46:15 $
     11 *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-09-14 23:48:25 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6565    p_psComponent* comp = psAlloc(sizeof(p_psComponent));
    6666
     67    p_psMemSetPersistent(comp,true);
    6768    p_psMemSetDeallocator(comp, (psFreeFcn) componentFree);
    6869    comp->name = psStringCopy(name);
     70    p_psMemSetPersistent((void*)comp->name,true);
    6971    comp->level = level;
    7072    comp->n = 0;
     
    8587    if (comp->subcomp != NULL) {
    8688        for (int i = 0; i < comp->n; i++) {
     89            p_psMemSetPersistent(comp->subcomp[i],false);
    8790            psFree(comp->subcomp[i]);
    8891        }
     92        p_psMemSetPersistent(comp->subcomp,false);
    8993        psFree(comp->subcomp);
    9094    }
    9195
    92     psFree((char *)comp->name);
     96    p_psMemSetPersistent((void*)comp->name,false);
     97    psFree((void*)comp->name);
    9398}
    9499
     
    195200            currentNode->subcomp = psRealloc(currentNode->subcomp,
    196201                                             (currentNode->n + 1) * sizeof(p_psComponent* ));
     202            p_psMemSetPersistent(currentNode->subcomp,true);
     203
    197204            currentNode->n = (currentNode->n) + 1;
    198205
  • trunk/psLib/test/dataManip/tst_psFunc00.c

    r1809 r1810  
    237237
    238238    psFree(my3DPolyD);
    239     memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
     239    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
    240240    if (0 != memLeaks) {
    241241        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
     
    271271
    272272    psFree(my4DPolyD);
    273     memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
     273    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
    274274    if (0 != memLeaks) {
    275275        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
     
    301301
    302302    psFree(my1DPoly);
    303     memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
     303    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
    304304    if (0 != memLeaks) {
    305305        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
     
    330330
    331331    psFree(my2DPoly);
    332     memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
     332    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
    333333    if (0 != memLeaks) {
    334334        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
     
    361361
    362362    psFree(my3DPoly);
    363     memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
     363    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
    364364    if (0 != memLeaks) {
    365365        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
     
    395395
    396396    psFree(my4DPoly);
    397     memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
     397    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
    398398    if (0 != memLeaks) {
    399399        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
     
    425425
    426426    psFree(my1DPolyD);
    427     memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
     427    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
    428428    if (0 != memLeaks) {
    429429        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
     
    451451
    452452    psFree(my2DPolyD);
    453     memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
     453    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
    454454    if (0 != memLeaks) {
    455455        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
     
    482482
    483483    psFree(my3DPolyD);
    484     memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
     484    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
    485485    if (0 != memLeaks) {
    486486        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
     
    516516
    517517    psFree(my4DPolyD);
    518     memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
     518    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
    519519    if (0 != memLeaks) {
    520520        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
  • trunk/psLib/test/dataManip/tst_psMinimize05.c

    r1800 r1810  
    9999
    100100    psMemCheckCorruption(1);
    101     memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
     101    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
    102102    if (0 != memLeaks) {
    103103        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
  • trunk/psLib/test/dataManip/tst_psStats07.c

    r1406 r1810  
    402402
    403403    psMemCheckCorruption( 1 );
    404     memLeaks = psMemCheckLeaks( currentId, NULL, NULL );
     404    memLeaks = psMemCheckLeaks( currentId, NULL, stderr );
    405405    if ( 0 != memLeaks ) {
    406406        psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks );
  • trunk/psLib/test/psTest.c

    r1699 r1810  
    149149            int currentId = psMemGetId();
    150150            int retVal = fcn();
    151             psErrorClear(); // clear the error stack before checking for leaks
    152             psTraceReset();
    153151            if ( retVal == 0 ) { // only bother checking memory if test executed to end.
    154152                if ( psMemCheckLeaks( currentId, NULL, stderr ) != 0 ) {
     
    175173        int currentId = psMemGetId();
    176174        childReturn = fcn();
    177         psErrorClear(); // clear the error stack before checking for leaks
    178         psTraceReset();
    179175        if ( childReturn == 0 ) { // only bother checking memory if test executed to end.
    180176            if ( psMemCheckLeaks( currentId, NULL, stderr ) != 0 ) {
Note: See TracChangeset for help on using the changeset viewer.