Memory leaks found
Posted: 2010-03-30T02:52:50-07:00
Here is the program that produces leaks.
You don't need as much files, you can only use 2 files if you want. The pictures are in TIFF format, about 100Megapixels, 11000*9000.
After a while malloc returns null and the files are being cached on disk. I have 4GB of ram and in the task manager I can see that this program uses only 500-900MB of ram.
However, the caching still happens, and I suspect it has something to do with these memory leaks. I am using WindowsXP SP3, 32bit.
The leaks happen in resize method. If I dont do finalImage = inputImage, and only work on inputImage, then the leaks are gone. This however is not an option for me.
This Bug is related with this topic: viewtopic.php?f=2&t=15895
The leaks were found using Trial verisions of Parasoft Insure++ and IBM Purify.
Thank you for your time and effort.
Code: Select all
#include "stdafx.h"
#include <Magick++.h>
#include <iostream>
#include <windows.h>
using namespace std;
using namespace Magick;
#define numberOfFiles 257
string dir;
string inputImageFileName;
string outputImageFileName;
string fileNames[numberOfFiles] = {"00114.TIF",
"00116.TIF",
"00215.TIF",
"00216.TIF",
"00309.TIF",
"00310.TIF",
"00311.TIF",
"00313.TIF",
"00314.TIF",
"00315.TIF",
"00410.TIF",
"00412.TIF",
"00414.TIF",
"00415.TIF",
"00416.TIF",
"00509.TIF",
"00513.TIF",
"00514.TIF",
"00603.TIF",
"00604.TIF",
"00606.TIF",
"00607.TIF",
"00608.TIF",
"00609.TIF",
"00610.TIF",
"00611.TIF",
"00612.TIF",
"00613.TIF",
"00614.TIF",
"00615.TIF",
"00616.TIF",
"00701.TIF",
"00702.TIF",
"00703.TIF",
"00704.TIF",
"00705.TIF",
"00706.TIF",
"00707.TIF",
"00708.TIF",
"00709.TIF",
"00710.TIF",
"00711.TIF",
"00712.TIF",
"00713.TIF",
"00714.TIF",
"00715.TIF",
"00716.TIF",
"00801.TIF",
"00802.TIF",
"00803.TIF",
"00804.TIF",
"00805.TIF",
"00806.TIF",
"00807.TIF",
"00808.TIF",
"00809.TIF",
"00810.TIF",
"00811.TIF",
"00812.TIF",
"00813.TIF",
"00814.TIF",
"00815.TIF",
"00816.TIF",
"00901.TIF",
"00902.TIF",
"00905.TIF",
"00906.TIF",
"00907.TIF",
"00909.TIF",
"00910.TIF",
"00911.TIF",
"00912.TIF",
"00913.TIF",
"00914.TIF",
"00915.TIF",
"00916.TIF",
"01102.TIF",
"01103.TIF",
"01104.TIF",
"01105.TIF",
"01106.TIF",
"01107.TIF",
"01108.TIF",
"01109.TIF",
"01110.TIF",
"01111.TIF",
"01112.TIF",
"01113.TIF",
"01114.TIF",
"01115.TIF",
"01116.TIF",
"01201.TIF",
"01202.TIF",
"01203.TIF",
"01204.TIF",
"01205.TIF",
"01206.TIF",
"01207.TIF",
"01208.TIF",
"01209.TIF",
"01210.TIF",
"01211.TIF",
"01212.TIF",
"01213.TIF",
"01214.TIF",
"01215.TIF",
"01216.TIF",
"01301.TIF",
"01302.TIF",
"01303.TIF",
"01304.TIF",
"01305.TIF",
"01306.TIF",
"01307.TIF",
"01308.TIF",
"01309.TIF",
"01310.TIF",
"01311.TIF",
"01312.TIF",
"01313.TIF",
"01314.TIF",
"01315.TIF",
"01316.TIF",
"01401.TIF",
"01402.TIF",
"01403.TIF",
"01404.TIF",
"01405.TIF",
"01406.TIF",
"01407.TIF",
"01408.TIF",
"01409.TIF",
"01410.TIF",
"01411.TIF",
"01412.TIF",
"01413.TIF",
"01414.TIF",
"01415.TIF",
"01416.TIF",
"01501.TIF",
"01502.TIF",
"01503.TIF",
"01504.TIF",
"01505.TIF",
"01506.TIF",
"01507.TIF",
"01508.TIF",
"01509.TIF",
"01510.TIF",
"01511.TIF",
"01512.TIF",
"01513.TIF",
"01514.TIF",
"01515.TIF",
"01516.TIF",
"01601.TIF",
"01602.TIF",
"01603.TIF",
"01604.TIF",
"01605.TIF",
"01606.TIF",
"01607.TIF",
"01608.TIF",
"01609.TIF",
"01610.TIF",
"01611.TIF",
"01612.TIF",
"01613.TIF",
"01614.TIF",
"01615.TIF",
"01616.TIF",
"01701.TIF",
"01705.TIF",
"01709.TIF",
"01710.TIF",
"01713.TIF",
"02402.TIF",
"02403.TIF",
"02404.TIF",
"02406.TIF",
"02407.TIF",
"02408.TIF",
"02410.TIF",
"02411.TIF",
"02412.TIF",
"02416.TIF",
"02501.TIF",
"02502.TIF",
"02503.TIF",
"02504.TIF",
"02505.TIF",
"02506.TIF",
"02507.TIF",
"02508.TIF",
"02509.TIF",
"02510.TIF",
"02511.TIF",
"02512.TIF",
"02514.TIF",
"02515_16.TIF",
"02601.TIF",
"02602.TIF",
"02603.TIF",
"02604.TIF",
"02605.TIF",
"02606.TIF",
"02607.TIF",
"02608.TIF",
"02609.TIF",
"02610.TIF",
"02611.TIF",
"02612.TIF",
"02613.TIF",
"02615.TIF",
"02616.TIF",
"02701.TIF",
"02702.TIF",
"02703.TIF",
"02704.TIF",
"02705.TIF",
"02706.TIF",
"02707.TIF",
"02708.TIF",
"02709.TIF",
"02710.TIF",
"02711.TIF",
"02712.TIF",
"02713.TIF",
"02714.TIF",
"02715.TIF",
"02716.TIF",
"02801.TIF",
"02802.TIF",
"02803.TIF",
"02804.TIF",
"02805.TIF",
"02806.TIF",
"02807.TIF",
"02808.TIF",
"02901.TIF",
"02905.TIF",
"04303.TIF",
"04304.TIF",
"04307.TIF",
"04308.TIF",
"04310.TIF",
"04311.TIF",
"04312.TIF",
"04315.TIF",
"04316.TIF",
"04401.TIF",
"04402.TIF",
"04403.TIF",
"04404.TIF",
"04405.TIF",
"04406.TIF",
"04409.TIF"
};
int main(int argc, char** argv)
{
dir = "D:/Temp/";
Magick::InitializeMagick(*argv);
try
{
long time = GetTickCount();
Geometry geometry = Geometry(1024,768);
Geometry cropGeometry = Geometry(2000,1000);
Magick::Image inputImage;
Magick::Image finalImage;
for (int i = 0; i<numberOfFiles; i++)
{
inputImageFileName = fileNames[i];
inputImage.read(dir+inputImageFileName);
finalImage = inputImage;
finalImage.crop(cropGeometry);
finalImage.resize(geometry);
outputImageFileName = inputImageFileName+"_out.TIF";
finalImage.write(dir+outputImageFileName);
}
cout << GetTickCount() - time << endl;
}catch(Magick::Exception& e)
{
cout << e.what() << endl;
}
return 0;
}
After a while malloc returns null and the files are being cached on disk. I have 4GB of ram and in the task manager I can see that this program uses only 500-900MB of ram.
However, the caching still happens, and I suspect it has something to do with these memory leaks. I am using WindowsXP SP3, 32bit.
The leaks happen in resize method. If I dont do finalImage = inputImage, and only work on inputImage, then the leaks are gone. This however is not an option for me.
This Bug is related with this topic: viewtopic.php?f=2&t=15895
The leaks were found using Trial verisions of Parasoft Insure++ and IBM Purify.
Thank you for your time and effort.