IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 21, 2025, 11:05:48 AM (18 months ago)
Author:
tdeboer
Message:

ppMerge memory leak, ppMerge changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppMerge/src/ppMergeLoop.c

    r42764 r42785  
    3939    bool haveVariances = psMetadataLookupBool(&mdok, arguments, "INPUTS.VARIANCES"); // Do we have variances?
    4040
    41     psArray *inputs = ppMergeFileDataLevel(config, "PPMERGE.INPUT", PM_FPA_LEVEL_READOUT); // Input images
    42     psArray *masks = NULL, *variances = NULL; // Input masks and variances
    43     if (haveMasks) {
    44         masks = ppMergeFileDataLevel(config, "PPMERGE.INPUT.MASK", PM_FPA_LEVEL_READOUT);
    45     }
    46     if (haveVariances) {
    47         variances = ppMergeFileDataLevel(config, "PPMERGE.INPUT.VARIANCE", PM_FPA_LEVEL_READOUT);
    48     }
     41    psArray *inputs    = ppMergeFileDataLevel(config, "PPMERGE.INPUT"); // Input images
     42    psArray *masks     = haveMasks ? ppMergeFileDataLevel(config, "PPMERGE.INPUT.MASK") : NULL; // Input masks
     43    psArray *variances = haveVariances ? ppMergeFileDataLevel(config, "PPMERGE.INPUT.VARIANCE") : NULL; // Input variances
    4944
    5045    int nThreads = psMetadataLookupS32 (&mdok, arguments, "NTHREADS");
     
    135130    psString darkNorm = psMetadataLookupStr(&mdok, arguments, "DARK.NORM"); ///< Dark normalisation
    136131
    137 
    138132    if (!ppMergeFileActivate(config, PPMERGE_FILES_ALL, true)) {
    139133        psError(PS_ERR_UNKNOWN, false, "Unable to activate files.");
     
    152146    }
    153147
    154 
    155148    // Average concepts across inputs
    156149    {
     
    180173        {
    181174            psList *inChips = psListAlloc(NULL);
    182             for (int i=0; i < numFiles; i++) {
     175            for (int i = 0; i < numFiles; i++) {
    183176                pmChip *chip = pmFPAviewThisChip(view, ((pmFPAfile *)inputs->data[i])->fpa);
    184177                psListAdd(inChips, PS_LIST_TAIL, chip);
     
    193186
    194187        pmCell *outCell;                ///< Cell of interest
    195 
    196         // XXX TEST : force a single loop
    197         // outCell = pmFPAviewNextCell(view, outFPA, 1); {
    198188
    199189        while ((outCell = pmFPAviewNextCell(view, outFPA, 1))) {
     
    291281                psAssert (fileGroups->n > 0, "no valid file groups defined");
    292282                fileGroup = fileGroups->data[0];
     283
    293284                if (!pmDarkCombinePrepare(outCell, fileGroup->readouts, darkOrdinates, darkNorm)) {
    294285                    goto ERROR;
     
    305296                psAbort("Should never get here.");
    306297            }
     298            fprintf (stderr, "after pmDarkCombinePrepare / pmReadoutCombinePrepare:\n");
     299            psMemStats(true, NULL, NULL);
    307300
    308301            // Read input data by chunks
     
    357350                      // call: pmDarkCombine(outCell, fileGroup->readouts, iter, rej, maskVal);
    358351                      if (!psThreadJobAddPending(job)) {
    359                         //                          goto ERROR;
    360                         // continue; // I don't care.
     352                        // CZW commented this out with a note that this was needed to allow ppMerge to work even if some inputs are invalid.
     353                        // EAM thinks pmDarkCombine will only return FALSE if there is a programming or setup error (see pmDark.c:pmDarkCombine)
     354                        // if so, we should raise an error here.
     355                        // goto ERROR;
    361356                      }
    362357                      break;
     
    400395
    401396            psFree(fileGroups);
    402             //            psFree(zeros);
    403397
    404398            // XXX eventually need to keep both the shutter and the pattern, as we do with dark
     
    541535            }
    542536
     537            // free the data used by the input files (we need to do the work ourselves)
     538            for (int i = 0; i < numFiles; i++) {
     539                if (!ppMergeFileFreeInput(config, view, i)) {
     540                    psError(PS_ERR_UNKNOWN, false, "Unable to open file %d", i);
     541                    goto ERROR;
     542                }
     543            }
     544
    543545            psFree(outRO);
    544546            cellNum++;
     
    547549                goto ERROR;
    548550            }
     551
     552            // pmFPAfileIOList (config);
    549553        }
    550554
     
    564568    psFree(variances);
    565569    psFree(stats);
     570    psFree(zeros);
    566571    return true;
    567572
     
    573578    psFree(variances);
    574579    psFree(stats);
     580    psFree(zeros);
    575581    return false;
    576582}
Note: See TracChangeset for help on using the changeset viewer.