IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 8, 2006, 4:37:59 PM (20 years ago)
Author:
Paul Price
Message:

Working version with no memory leaks (on MegaCam splice images)!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppImage/src/ppMem.c

    r6260 r6396  
    5353
    5454    psMemBlock **leaks = NULL;          // List of leaks
    55     int nLeaks = psMemCheckLeaks(0, &leaks, leakFile, false); // Number of leaks
     55    int nLeaks = psMemCheckLeaks(0, &leaks, leakFile, true); // Number of leaks
    5656    fprintf(stderr, "%d leaks found:\n", nLeaks);
    57     for (int i = nLeaks - 1; i > 0; i--) {
     57    for (int i = nLeaks - 1; i >= 0; i--) {
    5858        ppMemPrint(leaks[i]);
    5959    }
     
    6363    fprintf(stderr, "%d memory blocks corrupted.\n", nCorrupted);
    6464}
     65
     66void ppMemUsed(void)
     67{
     68    psMemBlock **leaks = NULL;          // List of leaks
     69    int nLeaks = psMemCheckLeaks(0, &leaks, NULL, true); // Number of leaks
     70    size_t total = 0;                   // Total size
     71    size_t largest = 0;                 // Largest block size
     72    psMemId index = -1;                 // Id number of largest block
     73    for (int i = nLeaks - 1; i >= 0; i--) {
     74        psMemBlock *mb = leaks[i];
     75        if (mb->userMemorySize >= largest) {
     76            largest = mb->userMemorySize;
     77            index = mb->id;
     78        }
     79        total += mb->userMemorySize;
     80    }
     81    psFree(leaks);
     82
     83    psLogMsg(__func__, PS_LOG_INFO, "Memory used: %ld\nLargest id: %ld (%ld bytes)", total, index, largest);
     84
     85}
Note: See TracChangeset for help on using the changeset viewer.