IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 17, 2006, 4:54:10 PM (20 years ago)
Author:
Paul Price
Message:

Was having trouble with memory blowout. Added (compile-time) option
to read cells all at once, but this didn't fix anything (and hence
option now disabled). Turns out problem is in psRealloc, which was
being triggered by the vast number of psTrace calls:
pmReadoutCombine->psStats->psTrace->psStringAppend->psRealloc. Problem
was mitigated in psLib, but I have kept some of the diagnostic functions
around (#if-ed out) in case they are needed later.

File:
1 edited

Legend:

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

    r8405 r8417  
    99#include "ppMergeCombine.h"
    1010
     11#if 0
     12static psMemId memId = 0;
     13
     14static FILE *dumpFile = NULL;
     15
     16static psMemId mbAlloc(psMemBlock *mb)
     17{
     18    if (!dumpFile) {
     19        dumpFile = fopen("memBlocks.dat", "w");
     20    }
     21    fprintf(dumpFile, "Alloc: %12lu\t%12zd\t%s:%d\n", mb->id, mb->userMemorySize,
     22            mb->file, mb->lineno);
     23    return 1;
     24}
     25
     26static void dumpDone(void)
     27{
     28    fclose(dumpFile);
     29    exit(EXIT_FAILURE);
     30}
     31
     32
     33static void memDump(void)
     34{
     35    psMemBlock **leaks = NULL;
     36    int numLeaks = psMemCheckLeaks(memId, &leaks, NULL, true);
     37    FILE *memFile = fopen("mem.dat", "w");
     38    fprintf(memFile, "# MemBlock Size Source\n");
     39    for (int i = 0; i < numLeaks; i++) {
     40        psMemBlock *mb = leaks[i];
     41        fprintf(memFile, "%12lu\t%12zd\t%s:%d\n", mb->id, mb->userMemorySize,
     42                mb->file, mb->lineno);
     43    }
     44    fclose(memFile);
     45    psFree(leaks);
     46}
     47
    1148static void memCheck(void)
    1249{
     50    return;
    1351    if (psTraceGetLevel(__func__) > 9) {
    1452        psMemBlock **leaks = NULL;
     
    3270    return;
    3371}
    34 
     72#endif
    3573
    3674// Combine the inputs
     
    4280    )
    4381{
    44 
    4582    psArray *filenames = psMetadataLookupPtr(NULL, config->arguments, "INPUT"); // The input file names
    4683    assert(filenames);                  // It should be here --- it's put here in ppMergeConfig
     
    86123            }
    87124
     125#if 1
     126            // Read bit by bit
     127
    88128            int numRead;  // Number of inputs read
    89129            int numScan = 0;
     
    124164                numScan++;
    125165
    126                 memCheck();
    127 
    128166            } while (numRead > 0);
     167
     168#else
     169            // Read whole cells at a time
     170
     171            printf("Chip %d, cell %d\n", i, j);
     172            int numRead = 0;  // Number of inputs read
     173            for (int k = 0; k < filenames->n; k++) {
     174                if (! filenames->data[k] || strlen(filenames->data[k]) == 0) {
     175                    continue;
     176                }
     177                psFits *fits = data->files->data[k]; // FITS file handle
     178                if (!fits) {
     179                    psError(PS_ERR_IO, false, "Unable to open input file %s --- ignored.\n",
     180                            filenames->data[k]);
     181                    continue;
     182                }
     183                pmFPA *fpaIn = data->in->data[k]; // Input FPA
     184                pmChip *chipIn = fpaIn->chips->data[i]; // Input chip
     185                pmCell *cellIn = chipIn->cells->data[j]; // Input cell
     186                if (!cellIn->file_exists || !cellIn->data_exists) {
     187                    continue;
     188                }
     189                if (!pmCellRead(cellIn, fits, config->database) || cellIn->readouts->n == 0) {
     190                    continue;
     191                }
     192                stack->data[k] = cellIn->readouts->data[0];
     193                numRead++;
     194            }
     195            if (numRead > 0) {
     196                pmReadoutCombine(readout, stack, cellZeros, cellScales, options->combine);
     197                psTrace(__func__, 5, "Chip %d, cell %d\n", i, j);
     198            }
     199
     200            memCheck();
     201#endif
     202
    129203            psFree(readout);            // Drop reference
    130204            psFree(stack);
     
    144218                pmCellFreeData(cell);
    145219            }
    146 
    147             memCheck();
    148220        }
    149221
     
    161233            pmChipFreeData(chip);
    162234        }
    163 
    164         memCheck();
    165235    }
    166236
     
    178248    pmFPAFreeData(data->out);
    179249
    180     memCheck();
    181 
    182250    return true;
    183 }
     251
     252}
Note: See TracChangeset for help on using the changeset viewer.