Click here to Skip to main content
15,302,644 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I am developing a program which has some basic image processing filters and raster to vector convertion fonctions. I am working with bmp, jpeg, png, tiff and geotiff files. The images that i work on can be very big. When i try to open a 190mb bmp file (7000*9000 pixels), i get an exception like "Insufficient memory to continue the execution of the program". My computer has 6GB memory and i try to run my program on 64x CPU. I googled it but couldn't find a good solution. I don't know what the reason can be.

Thanks for any help.
Updated 7-Jul-21 0:02am
Sergey Alexandrovich Kryukov 11-Apr-14 10:56am
The file is certainly too big (why, by the way?), but, just in case: are you really sure that at least one of your assemblies is not targeted to a 32-bit instruction-set architecture? Then the application could be executed by WoW64. Ideally, all targets should be "AnyCPU"...
Maciej Los 11-Apr-14 12:47pm
Did you check via task manager how much memory is currently consumed by your program? I think there is a memory leak problem.
phil.o 11-Apr-14 12:55pm
I think I read somewhere (but I may be wrong) that, regardless of the amount of RAM the computer has, there is a 2 Gb limit of memory a single object can consume.
Çağrı Daşkın 11-Apr-14 15:23pm
Hello all,
Thank you all for your answers. The images are used in aerial photogrametry. Each photo shows a big area of earth surface. That's why they are so big. Making the platform target "Any CPU" didn't work. My program consumes about 1,5-1,7 gb memory while working with big images. And if what phil says is true, yes, this must be the problem. But i have to work with those big images. Is there any way to make all available memory accesible?
Andrius Leonavicius 11-Apr-14 16:29pm

phil.o is right, memory limit of the .NET object is 2 GB. .NET Framework 4.5 arrays can be greater than 2 GB. Link:

By the way, there is an article about the memory limits. Link:
Çağrı Daşkın 11-Apr-14 17:06pm
Hi Andrius,

Thank you for your help.
Andrius Leonavicius 11-Apr-14 17:09pm
You're welcome. Please let me know if that solved your problem.
Çağrı Daşkın 14-Apr-14 3:09am
Hi Andrius,

Thank you again, i don't get the exception now. But this time, i have another problem. After a few seconds i start the process, my computer freezes. I can't understand how an image process can consume that big amount of memory. I work with BitmapData class. A bitmapdata object includes image width * image height units. In every unit there are 3 bytes of pixel information(for 3 band images). 7000*9000*3 = 189mb. I will try splitting the image into 4 pieces.
Andrius Leonavicius 14-Apr-14 12:01pm

Have you tried with small images? Maybe there is something wrong with your code. Also, I have found this post:
Çağrı Daşkın 16-Apr-14 2:08am
Hi Andrius,

My code works perfectly with small images. Still there must be another problem and i have to find it :) Thank you for sharing the link.
#realJSOP 10-Jul-21 7:52am
Maybe your code is making an assumption about an array size somewhere. I would start with adding Debug.WriteLine statements in the associated code and watch what it does in the output window.
Roger500 16-Jul-21 0:05am
Check the app.Config for
<gcallowverylargeobjects enabled="true">

On 64-bit platforms, it enables arrays that are greater than 2 gigabytes (GB) in total size.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900