[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Working with large images in VB.NET

Posted on 2004-08-20
Medium Priority
Last Modified: 2010-05-18
Hi im working on an application that is supposed to handle large images, now i seem to have some trouble with the bitmap object, seems it can only handle images that are like 10000px,10000px i dont know the exact number but this can be alittle too small sometimes...

but when i open smaller images ( < 10000x10000 but still really large) i get a "Out of memory" exception even tho the taskmanager reports just 170Mb memory used out of one GB of ram....

is it possible to break that limit and load say 3 times that amount of memory in bitmap objects so i can work with the three images at the same time...

well, its actually 4 since i create another graphics object and clone parts of the three input images to the output graphics object...

has anyone experience with working with large image files?

the reason that i need such large images is because they are supposed to be printed later on very large paper with very good quality... like 1Meter height and variable width...

Question by:JohnnyGr
  • 3
  • 3

Expert Comment

ID: 11857941
JohnnyGr: Understand that an image (lets say 10x10 pixel) but then twice so big (that makes 20x20) needs about 4 times more memory of uncompressed image data.

What program do you use?

Author Comment

ID: 11858254
im using my own program im trying to make...

but still... the application just uses 170 meggs of memory... and i have about 700mb free, plus swap so there should be more than enough memory to work with.. but i still get "Out Of Memory" exceptions....

Expert Comment

ID: 11859094
Okay... I understand that you use only 170 Mb. But I could be that for you NEXT operation you exceed the maximum mem, the program could predict you would exceed this amount and give you the error (so you would not see any change of mem usage in taskmanager)

My next guess (since nobody else helps you):

Mostly you get strange things like this if you not do clean/close used objects/var. Try to clear the graphics objects if you can... after/before you use it. Also when you close an application. Something like this: graphics_object.clear and resize its pixels down to a minimum.
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 14

Expert Comment

ID: 11866662
I have some experience with images in the hundreds of megabyte range using VB.Net.  One thing you will absolutely want to make sure you do is make sure you call the DISPOSE method on ALL graphics objects you create with the New keyword.  This includes Graphics, Brush, Pen objects.   DON'T rely on the objects to be released when they go out of scope.   If that doesn't have too much of an effect, try putting a call to GC.Collect to force the Garbage collector to run which will release any resources that are tagged for disposal.  Dealing with images this large requires very strict programming discipline to make sure you clean up after yourself as soon as you are done with the objects.   Basically, if you create an object with New and you are done with it, if it has a Dispose method...call it!  (Use intellisense (or the object browser) to see if it does).



Author Comment

ID: 11867644
Well i seem to have things going my way now...
I did as Daniellus83 and ptakja suggested and made sure i cleaned up everything ive been using... setting objects to disposed didnt work always tho.... but setting them to Nothing did. wich is kindof the same...

But it still seems that the bitmap object only can handle a image thats something like
10000px X 10000px and im trying to work with some really high resolution images for some advertisment, that are supposed to be printed on really big paper...

I dont really know much about the images more than i was asked if i could fix this...

Is there some way i can boost the number of pixels a bitmap object can hold?

Accepted Solution

Daniellus83 earned 750 total points
ID: 11868680
Dear JohnnyGr; You might waana read this 'interesting' topic:


It seems to be like yours.

  "...GDI run out of its allocated kernel memory (the still uncertain X percent of
                       my 512 megabytes of ram) and crash with the said internal windows message..."

Author Comment

ID: 12101765
Whops, looks like i forgot all about this, well this problem ended up with the project being abandoned because theres no way you can create larger images than 10000x10000 something, no matter how hard you try, and that caused the out of memory error, wich it throws for all kinds of reasons...... and the images i was supposed to open was alot larger than that...
and with higher resolution...


Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question