Fixed two memory leaks, one of it huge; see issue #636

This commit is contained in:
Oliver Duis
2011-04-15 21:19:09 +02:00
parent 63533713bb
commit 0105e3b522
7 changed files with 21 additions and 43 deletions

View File

@@ -119,8 +119,7 @@ namespace rtengine {
satcurvePoints.push_back(1);
satcurvePoints.push_back(1+saturation/200.0);
}
DiagonalCurve* satcurve = NULL;
satcurve = new DiagonalCurve (satcurvePoints, CURVES_MIN_POLY_POINTS/skip); // Actually, CURVES_MIN_POLY_POINTS = 1000,
DiagonalCurve* satcurve = new DiagonalCurve (satcurvePoints, CURVES_MIN_POLY_POINTS/skip); // Actually, CURVES_MIN_POLY_POINTS = 1000,
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// create a curve if needed
@@ -178,8 +177,8 @@ namespace rtengine {
boutCurve[i] = (65535.0 * dbcurve[i]);
satCurve[i] = (65535.0 * dscurve[i]);
}
//delete [] dcurve;
//delete satcurve;
delete satcurve;
}
@@ -251,8 +250,7 @@ namespace rtengine {
brightcurvePoints.push_back(1); // white point
brightcurvePoints.push_back(1); // value at white point
DiagonalCurve* brightcurve = NULL;
brightcurve = new DiagonalCurve (brightcurvePoints, CURVES_MIN_POLY_POINTS/skip); // Actually, CURVES_MIN_POLY_POINTS = 1000,
DiagonalCurve* brightcurve = new DiagonalCurve (brightcurvePoints, CURVES_MIN_POLY_POINTS/skip); // Actually, CURVES_MIN_POLY_POINTS = 1000,
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
float exp_scale = a;
@@ -347,8 +345,7 @@ namespace rtengine {
contrastcurvePoints.push_back(1); // white point
contrastcurvePoints.push_back(1); // value at white point
DiagonalCurve* contrastcurve = NULL;
contrastcurve = new DiagonalCurve (contrastcurvePoints, CURVES_MIN_POLY_POINTS/skip); // Actually, CURVES_MIN_POLY_POINTS = 1000,
DiagonalCurve* contrastcurve = new DiagonalCurve (contrastcurvePoints, CURVES_MIN_POLY_POINTS/skip); // Actually, CURVES_MIN_POLY_POINTS = 1000,
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// apply contrast enhancement
@@ -444,8 +441,7 @@ namespace rtengine {
brightcurvePoints.push_back(1); // white point
brightcurvePoints.push_back(1); // value at white point
DiagonalCurve* brightcurve = NULL;
brightcurve = new DiagonalCurve (brightcurvePoints, CURVES_MIN_POLY_POINTS/skip); // Actually, CURVES_MIN_POLY_POINTS = 1000,
DiagonalCurve* brightcurve = new DiagonalCurve (brightcurvePoints, CURVES_MIN_POLY_POINTS/skip); // Actually, CURVES_MIN_POLY_POINTS = 1000,
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for (int i=0; i<32768; i++) {//L values range up to 32767, higher values are for highlight overflow
@@ -494,14 +490,14 @@ namespace rtengine {
contrastcurvePoints.push_back(1); // white point
contrastcurvePoints.push_back(1); // value at white point
DiagonalCurve* contrastcurve = NULL;
contrastcurve = new DiagonalCurve (contrastcurvePoints, CURVES_MIN_POLY_POINTS/skip); // Actually, CURVES_MIN_POLY_POINTS = 1000,
DiagonalCurve* contrastcurve = new DiagonalCurve (contrastcurvePoints, CURVES_MIN_POLY_POINTS/skip); // Actually, CURVES_MIN_POLY_POINTS = 1000,
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// apply contrast enhancement
for (int i=0; i<32768; i++) {
dcurve[i] = contrastcurve->getVal (dcurve[i]);
}
delete contrastcurve;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -562,11 +558,4 @@ void CurveFactory::init () {
fclose (f);*/
}
void CurveFactory::cleanup () {
//delete [] gammatab;
//delete [] igammatab_srgb;
//delete [] gammatab_srgb;
}
}

View File

@@ -190,8 +190,6 @@ void Crop::update (int todo) {
// switch back to rgb
parent->ipf.lab2rgb (labnCrop, cropImg);
// this in workinging space is held in parallel to allow analysis like shadow/highlight
cropImgtrue = parent->ipf.lab2rgb (labnCrop, 0,0,cropw,croph, params.icm.working);
//parent->ipf.lab2rgb (laboCrop, cropImg);
//cropImg = baseCrop->to8();
@@ -227,6 +225,9 @@ void Crop::update (int todo) {
}
*/
if (cropImageListener) {
// this in workinging space is held in parallel to allow analysis like shadow/highlight
Image8 *cropImgtrue = parent->ipf.lab2rgb (labnCrop, 0,0,cropw,croph, params.icm.working);
int finalW = rqcropw;
if (cropImg->getWidth()-leftBorder < finalW)
finalW = cropImg->getWidth()-leftBorder;
@@ -243,6 +244,7 @@ void Crop::update (int todo) {
cropImageListener->setDetailedCrop (final, finaltrue, params.icm, params.crop, rqcropx, rqcropy, rqcropw, rqcroph, skip);
delete final;
delete finaltrue;
delete cropImgtrue;
}
}
@@ -345,7 +347,6 @@ if (settings->verbose) printf ("setcropsizes before lock\n");
laboCrop = new LabImage (cropw, croph);
labnCrop = new LabImage (cropw, croph);
cropImg = new Image8 (cropw, croph);
cropImgtrue = new Image8 (cropw, croph);
cshmap = new SHMap (cropw, croph, true);

View File

@@ -39,9 +39,7 @@ class Crop : public DetailedCrop {
Imagefloat* origCrop, *baseCrop;
Imagefloat* *resizeCrop, *transCrop;
LabImage *laboCrop, *labnCrop;
Image8 *cropImg;
Image8 *cropImgtrue;
Image8 *cropImg; // permanently allocated in RAM and only renewed on size changes
float** cbuffer;
float * cbuf_real;

View File

@@ -50,7 +50,6 @@ int init (const Settings* s) {
void cleanup () {
CurveFactory::cleanup ();
ImProcFunctions::cleanupCache ();
Thumbnail::cleanupGamma ();
}

View File

@@ -98,13 +98,12 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
else if (params.wb.method=="Auto")
currWB = imgsrc->getAutoWB ();
Imagefloat* baseImg;
PreviewProps pp (0, 0, fw, fh, 1);
imgsrc->preprocess( params.raw );
if (pl) pl->setProgress (0.20);
imgsrc->demosaic( params.raw );
if (pl) pl->setProgress (0.40);
baseImg = new Imagefloat (fw, fh);
Imagefloat* baseImg = new Imagefloat (fw, fh);
imgsrc->getImage (currWB, tr, baseImg, pp, params.hlrecovery, params.icm, params.raw);
if (pl) pl->setProgress (0.45);
@@ -158,7 +157,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
ipf.rgbProc (baseImg, labView, curve1, curve2, curve, shmap, params.toneCurve.saturation);
if (shmap)
delete shmap;
delete shmap;
if (pl)
pl->setProgress (0.5);
@@ -183,9 +182,6 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
ipf.dirpyrdenoise (labView);
ipf.sharpening (labView, (float**)buffer);
// color processing
/*ipf.colorCurve (labView, labView);
ipf.colordenoise (labView, buffer);*/
// wavelet equalizer
@@ -201,7 +197,6 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
if (pl) pl->setProgress (0.60);
// crop and convert to rgb16
Image16* readyImg;
int cx = 0, cy = 0, cw = labView->W, ch = labView->H;
if (params.crop.enabled) {
cx = params.crop.x;
@@ -209,7 +204,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
cw = params.crop.w;
ch = params.crop.h;
}
readyImg = ipf.lab2rgb16 (labView, cx, cy, cw, ch, params.icm.output);
Image16* readyImg = ipf.lab2rgb16 (labView, cx, cy, cw, ch, params.icm.output);
delete labView;
if (pl) pl->setProgress (0.70);

View File

@@ -108,10 +108,6 @@ CurveEditor::CurveEditor (Glib::ustring text, CurveEditorGroup* ceGroup, CurveEd
typeconn = curveType->signal_changed().connect (sigc::mem_fun(*this, &CurveEditor::typeSelectionChanged) );
}
CurveEditor::~CurveEditor () {
}
void CurveEditor::setCurve (const std::vector<double>& p) {
tempCurve = p;
group->setCurveExternal(this, p);

View File

@@ -66,7 +66,7 @@ class CurveEditor {
public:
CurveEditor (Glib::ustring text, CurveEditorGroup* ceGroup, CurveEditorSubGroup* ceSubGroup);
~CurveEditor ();
void typeSelectionChanged (int n);
void curveTypeToggled();
bool isUnChanged ();