Changeset 6396
- Timestamp:
- Feb 8, 2006, 4:37:59 PM (20 years ago)
- Location:
- trunk/ppImage/src
- Files:
-
- 5 edited
-
ppImage.c (modified) (3 diffs)
-
ppImageLoop.c (modified) (4 diffs)
-
ppImageOptions.c (modified) (1 diff)
-
ppMem.c (modified) (2 diffs)
-
ppMem.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppImage/src/ppImage.c
r6260 r6396 1 1 #include <stdio.h> 2 2 #include "pslib.h" 3 #include "pmConcepts.h" 3 4 #include "ppImage.h" 4 5 #include "ppMem.h" 5 6 6 7 7 int main(int argc, char **argv) … … 23 23 ppImageParseCamera(data, config); 24 24 25 // Cleaning up26 psFree(data);27 psFree(options);28 psFree(config);29 psTimerStop();30 ppMemCheck();31 #if 032 33 25 // Set various tasks (define optional operations) 34 26 ppImageOptionsParse(data, options, config); … … 39 31 // Image Arithmetic Loop 40 32 ppImageLoop(data, options, config); 41 #endif42 33 43 exit(EXIT_SUCCESS); 34 // Cleaning up 35 psFree(data); 36 psFree(options); 37 psFree(config); 38 psTimerStop(); 39 psTraceReset(); 40 pmConceptsDone(); 41 ppMemCheck(); 42 43 return EXIT_SUCCESS; 44 44 } -
trunk/ppImage/src/ppImageLoop.c
r6260 r6396 7 7 #include "ppImageDetrend.h" 8 8 #include "ppImage.h" 9 #include "ppMem.h" 9 10 10 11 #define MEM_LEAKS 1 … … 101 102 102 103 // Need to free detrend cells here so we have enough memory to do other stuff 103 #ifndef MEM_LEAKS104 104 psFree(detrend.bias); 105 105 psFree(detrend.dark); 106 106 psFree(detrend.mask); 107 107 psFree(detrend.flat); 108 #endif109 108 } 110 109 … … 114 113 // XXX EAM: Photometry goes here! 115 114 116 // A kludge to get the write to behave wrtthe concepts --- we've changed the camera format, so115 // XXX A kludge to get the write to behave w.r.t. the concepts --- we've changed the camera format, so 117 116 // the concepts don't know what on earth to do. 118 117 const psMetadata *camera = data->input->fpa->camera; … … 122 121 123 122 // Now I can blow away the mosaic so I can then read more. 124 #ifndef MEM_LEAKS 125 pmChipFreeCells(inputChip); 126 #endif 123 psFree(inputChip); 127 124 } 128 129 #if 0130 // Write out the mosaicked chip, just to see; this wouldn't normally happen131 psFits *mosaicFile = psFitsOpen("mosaic.fits", "w");132 for (int i = 0; i < chips->n; i++) {133 pmChip *chip = chips->data[i];134 if (! chip || ! chip->exists || ! chip->process) {135 continue;136 }137 #if 0138 psArray *cells = chip->cells;139 pmCell *cell = cells->data[0];140 psArray *readouts = cell->readouts;141 pmReadout *readout = readouts->data[0];142 psImage *image = readout->image;143 #else144 psImage *image = chip->hdu->images->data[0];145 #endif146 psFitsWriteImage(mosaicFile, NULL, image, 0);147 148 }149 #endif150 151 // Free the detrend FPA and chips152 #ifndef MEM_LEAKS153 psFree(data->bias);154 psFree(data->dark);155 psFree(data->mask);156 psFree(data->flat);157 #endif158 159 psFitsClose(data->output);160 125 161 126 return true; 162 127 } 163 164 /* if we allow per-readout loads, we need to load detrend images here */ -
trunk/ppImage/src/ppImageOptions.c
r6260 r6396 180 180 // Fill in the options 181 181 options->overscan = pmOverscanOptionsAlloc(overscanSingle, overscanFit, overscanOrder, overscanStats); 182 psFree(overscanStats); 182 183 } 183 184 -
trunk/ppImage/src/ppMem.c
r6260 r6396 53 53 54 54 psMemBlock **leaks = NULL; // List of leaks 55 int nLeaks = psMemCheckLeaks(0, &leaks, leakFile, false); // Number of leaks55 int nLeaks = psMemCheckLeaks(0, &leaks, leakFile, true); // Number of leaks 56 56 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--) { 58 58 ppMemPrint(leaks[i]); 59 59 } … … 63 63 fprintf(stderr, "%d memory blocks corrupted.\n", nCorrupted); 64 64 } 65 66 void 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 } -
trunk/ppImage/src/ppMem.h
r6260 r6396 8 8 void ppMemPrint(const psMemBlock *ptr); 9 9 void ppMemCheck(void); 10 void ppMemUsed(void); 10 11 11 12 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
