IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18393 for trunk/ppStack


Ignore:
Timestamp:
Jun 30, 2008, 6:27:12 PM (18 years ago)
Author:
Paul Price
Message:

Adding memory dumps to track down memory leaks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStack/src/ppStackLoop.c

    r18385 r18393  
    3030                             "SOURCE.PLOT.MOMENTS", "SOURCE.PLOT.PSFMODEL", "SOURCE.PLOT.APRESID",
    3131                             "PSPHOT.INPUT.CMF", NULL };
     32
     33static void memDump(const char *name)
     34{
     35    return;
     36
     37    static int num = 0;                 // Counter, to make files unique and give an idea of sequence
     38
     39    psString filename = NULL;           // Name of file
     40    psStringAppend(&filename, "memdump_%s_%03d.txt", name, num);
     41    FILE *memFile = fopen(filename, "w");
     42    psFree(filename);
     43
     44    psMemBlock **leaks = NULL;
     45    int numLeaks = psMemCheckLeaks(0, &leaks, NULL, true);
     46    fprintf(memFile, "# MemBlock Size Source\n");
     47    unsigned long total = 0;            // Total memory used
     48    for (int i = 0; i < numLeaks; i++) {
     49        psMemBlock *mb = leaks[i];
     50        fprintf(memFile, "%12lu\t%12zd\t%s:%d\n", mb->id, mb->userMemorySize,
     51                mb->file, mb->lineno);
     52        total += mb->userMemorySize;
     53    }
     54    fclose(memFile);
     55    psFree(leaks);
     56
     57    fprintf(stderr, "Memdump %s %d: Memory use: %ld, sbrk: %p\n", name, num, total, sbrk(0));
     58    num++;
     59}
     60
    3261
    3362
     
    210239    psMetadata *ppsub = psMetadataLookupMetadata(NULL, config->recipes, "PPSUB"); // PPSUB recipe
    211240    int overlap = 2 * psMetadataLookupS32(NULL, ppsub, "KERNEL.SIZE"); // Overlap by kernel size between consecutive scans
     241
     242    memDump("start");
    212243
    213244    // Preparation iteration: Load the sources, and get a target PSF model
     
    328359    }
    329360
     361    memDump("psf");
     362
    330363    const char *outName = psMetadataLookupStr(NULL, config->arguments, "OUTPUT"); // Output root
    331364    assert(outName);
     
    389422        filesIterateUp(config);
    390423        numGood++;
     424
     425        memDump("match");
    391426    }
    392427    psFree(globalSources);
     
    405440#endif
    406441
     442    memDump("preinitial");
    407443
    408444    // Stack the convolved files
     
    524560            }
    525561        }
     562
     563        memDump("initial");
    526564
    527565        // Reset for the second read
     
    574612            }
    575613            rejected->data[i] = reject;
     614
     615            memDump("reject");
     616
    576617        }
    577618        psFree(subKernels);
     
    586627            return false;
    587628        }
     629
     630        memDump("prefinal");
    588631
    589632        // Read convolutions by chunks
     
    689732        psFree(weightFits);
    690733
     734        memDump("final");
     735
    691736        if (psMetadataLookupBool(&mdok, config->arguments, "PHOTOMETRY")) {
    692737
     
    708753        }
    709754
     755        memDump("phot");
     756
    710757        // Statistics on output
    711758        if (stats) {
     
    713760            ppStatsFPA(stats, outCell->parent->parent, view, maskBlank, config);
    714761        }
     762
     763        memDump("stats");
    715764
    716765        // Put version information into the header
     
    746795    }
    747796
     797    memDump("finish");
     798
    748799    return true;
    749800}
Note: See TracChangeset for help on using the changeset viewer.