Reputation: 251
I am processing very large images but I get an exception that informs me "Failed to allocate 991623040 bytes"
I have 64bit Win7 and 8GB ram. Isn't it ridiculus that failing when smaller than 1GB?
How can I solve this problem?
public bresenhamCircle()
{
if (path != null) //path is a string represents the file path
{
using (IplImage orgImg = new IplImage(rc.imgeYolu, LoadMode.GrayScale))
{
if (rc.sekizBit)
{
orgImg.ToBitmap();
}
else
{
//binary image
}
using (IplImage imgLabel = new IplImage(orgImg.Size, BitDepth.F32, 1))
{
using (CvBlobs blobs = new CvBlobs())
{
uint result = blobs.Label(orgImg, imgLabel);
blobs.FilterByArea(10, 130);
}
}
}
}
else
{
throw new Exception("smtg..");
}
}
I am getting the error message at this line : using (IplImage imgLabel = new IplImage(orgImg.Size, BitDepth.F32, 1))
Upvotes: 3
Views: 6573
Reputation: 136
If you not running your application in 64 bit mode then you are not using 8 GB of RAM. Also out of memory is caused by insufficient contiguous virutal address spaces not physical address spaces refer article http://vpnchoudhary.blogspot.com/2011/03/out-of-memory-exception-simple.html for details on how memory mgmt of 32 bit application.
First verify if your appication is running in 64 or not. Open task mgr and see if your appication is appended by *32 at the end. if yes then your application is running in 32 bit mode. Compile your application for 64 bit. it should resolve your issue. If your application is already running in 64 bit then your appliation is leaking memory, but i highly doubt it as you are using "using" which should take care of disposing object. Also with 64 bit application you got huge virtual address spaces which is hard of exhaust, you application will start thrashing (very slow) but will rarely go out of memory.
Upvotes: 1
Reputation: 1762
It could be several reasons; most likely because you have memory leaks. We would need to see your code, the code above looks like you are not declaring the images at pointers using the "*" operator, but that is probably a typo. Also just because you have 64 bit windows and 8 GB of RAM, if you are using a 32 bit build of opencv, you only have access to 2 GB of RAM. I would recommend downloading the latest SVN version of opencv and building in 64 bit mode and enabling tbb.
Upvotes: 1