Memory problem

Hi guys,
I have a BIG problem. Though I am not doing game programming right
now, I am making an application which loads two HUGE bitmaps (250MB+
each) into memory for some purpose. I am using MFC for developing it.

Do you have any idea how it can be done without taking a lot of time
and lot of memory?? I have 256 MB RAM.

My app was able to load 60 MB bitmap image easily. But images of
sizes 150 MB bug my computer. In future I will be handling images of
size like 2GB or so.

I know that large data can be managed by loading small chunks and
handling them instead of the whole data. But unfortunately I am new
to such tricks. Any nice suggestion? Any sample code will help me a
lot!

Thanks,
Nayan

— Nayan Choudhary wrote:

I have a BIG problem. Though I am not doing game programming right
now, I am making an application which loads two HUGE bitmaps (250MB+
each) into memory for some purpose. I am using MFC for developing it.

Do you have any idea how it can be done without taking a lot of time
and lot of memory?? I have 256 MB RAM.

My app was able to load 60 MB bitmap image easily. But images of
sizes 150 MB bug my computer. In future I will be handling images of
size like 2GB or so.

I know that large data can be managed by loading small chunks and
handling them instead of the whole data. But unfortunately I am new
to such tricks. Any nice suggestion? Any sample code will help me a
lot!

Um… shrink your bitmaps? What in Heaven’s name do you need a 250
MB bitmap for?

Without more details, it’s hard to really suggest anything. The
number of standard application types that really need to have a 250
MB chunk of image data on hand is pretty limited.

                                                         NBarnes__________________________________

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

First of all, what exactly will your program do?

Part of the solution could depend on the image format you use. Some formats
will let you load directly from them in pieces (like the SGI image format,
which you can read in one scanline at a time).

Otherwise, just write a system that will spool the images out to disk as it
loads and decompresses them. I don’t know a lot about Windows programming, so
the actual method is left up to you.

The trouble is that most image loading libraries expect to be able to load the
entire image into memory at once. Unless you want to write your own image
loader, you’re going to have to find a way around this. And idea I just had
that might work (at least on Linux, dunno about Windows) would be to use
memory mapped files. Basically, memory mapped files can be used like a char
array. So, what you do is instead of passing the image library a nice big
250MB memory buffer for it to load the image into, you pass it a pointer to
your memory mapped file (which the image library will think is a pointer to a
memory buffer). This will be slower than loading directly into memory (unless
you’re trying to load a 250MB image on a system with 256MB of RAM, in which
case the speed should be about the same), but the advantage would be that you
get the equivalent of a memory dump of the final, loaded and uncompressed
image. You can then close the memory mapped file, open it as a regular file,
load smaller chunks of this “memory dump” into a fixed-size buffer and do
what you want with them.

The method that programs like The Gimp use is to just bite the bullet and
initially load the entire image into memory (not workable for 2GB images
though). After that, it is broken up into fixed-size tiles, which are written
to a temporary cache on disk and then removed from memory. As the tiles are
needed, they are loaded into memory, used, and then flushed back out to the
temporary disk cache. Obviously, the program needs extra mechanisms to keep
track of which tiles are where in the cache, to keep track of what tiles are
needed when (and when they stop being needed), etc.

Play around, possibly have a look at The Gimp’s tile manager code, and find
something that works for you. You might also want to check out CinePaint’s
(http://cinepaint.sourceforge.net) tile manager code, since CinePaint was
originally based on an older version of The Gimp, and so its tile manager
code might be simpler and easier to understand.

Hope this helps.
-Sean RidenourOn Thursday 18 September 2003 4:27 am, Nayan Choudhary wrote:

Hi guys,
I have a BIG problem. Though I am not doing game programming right
now, I am making an application which loads two HUGE bitmaps (250MB+
each) into memory for some purpose. I am using MFC for developing it.

Do you have any idea how it can be done without taking a lot of time
and lot of memory?? I have 256 MB RAM.

My app was able to load 60 MB bitmap image easily. But images of
sizes 150 MB bug my computer. In future I will be handling images of
size like 2GB or so.

I know that large data can be managed by loading small chunks and
handling them instead of the whole data. But unfortunately I am new
to such tricks. Any nice suggestion? Any sample code will help me a
lot!

To come with any concrete ideas on how to handle such big files we have to
know moare about what you plan to do with the images once loaded. This is
for the simple reason that different usage requires different approaches.

If you give us some more info we might be able to come up with a clever plan
:wink:

Best regards
Daniel Liljeberg> ----- Original Message -----

From: nayanchoudhary@yahoo.com (Nayan Choudhary)
To:
Sent: Thursday, September 18, 2003 1:27 PM
Subject: [SDL] Memory problem

Hi guys,
I have a BIG problem. Though I am not doing game programming right
now, I am making an application which loads two HUGE bitmaps (250MB+
each) into memory for some purpose. I am using MFC for developing it.

Do you have any idea how it can be done without taking a lot of time
and lot of memory?? I have 256 MB RAM.

My app was able to load 60 MB bitmap image easily. But images of
sizes 150 MB bug my computer. In future I will be handling images of
size like 2GB or so.

I know that large data can be managed by loading small chunks and
handling them instead of the whole data. But unfortunately I am new
to such tricks. Any nice suggestion? Any sample code will help me a
lot!

Thanks,
Nayan


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

To echo what other people have said, we need to know more about the problem…
what are the images? Gigantic satellite weather images? Or something a
little more mundane/compressible? And what are you doing with it - shrinking
it and showing it all at once, or just using little sections of it one at a
time?

One way to do it, I suppose, would be to just plain cut it into quarters or
sixteenths - each section a seperate file - and only load the ones you need
at any given time… a little more complicated to display, but certainly not
impossible.On Thursday 18 September 2003 05:27 am, Nayan Choudhary wrote:

Hi guys,
I have a BIG problem. Though I am not doing game programming right
now, I am making an application which loads two HUGE bitmaps (250MB+
each) into memory for some purpose. I am using MFC for developing it.

Do you have any idea how it can be done without taking a lot of time
and lot of memory?? I have 256 MB RAM.

My app was able to load 60 MB bitmap image easily. But images of
sizes 150 MB bug my computer. In future I will be handling images of
size like 2GB or so.

I know that large data can be managed by loading small chunks and
handling them instead of the whole data. But unfortunately I am new
to such tricks. Any nice suggestion? Any sample code will help me a
lot!

Thanks,
Nayan

I would just like to know… What could you possible want to load a 2GB
BMP… What could possible make this so big in size? Is it a Hugh image
file… Are you making a 3D world type thing were you can zoom in to see
your house? or something that is the basics of this just not the world?

If so I would cut up the images and load the cut parts in order need…

Also… 2GB images file… I hope you are going to load them off a server or
something if this is a project you are going to release bemuse I would not
download a 2GB image or small images =ing that… And some one with
bandwidth challenged cant download it either… Just some for you to think
about (if you have not) if you are going to release this…

Andrew

“Tyler Montbriand” wrote in message
news:200309211441.34607.tsm at accesscomm.ca
To echo what other people have said, we need to know more about the
problem…
what are the images? Gigantic satellite weather images? Or something a
little more mundane/compressible? And what are you doing with it -
shrinking
it and showing it all at once, or just using little sections of it one at a
time?

One way to do it, I suppose, would be to just plain cut it into quarters or
sixteenths - each section a seperate file - and only load the ones you need
at any given time… a little more complicated to display, but certainly not
impossible.On Thursday 18 September 2003 05:27 am, Nayan Choudhary wrote:

Hi guys,
I have a BIG problem. Though I am not doing game programming right
now, I am making an application which loads two HUGE bitmaps (250MB+
each) into memory for some purpose. I am using MFC for developing it.

Do you have any idea how it can be done without taking a lot of time
and lot of memory?? I have 256 MB RAM.

My app was able to load 60 MB bitmap image easily. But images of
sizes 150 MB bug my computer. In future I will be handling images of
size like 2GB or so.

I know that large data can be managed by loading small chunks and
handling them instead of the whole data. But unfortunately I am new
to such tricks. Any nice suggestion? Any sample code will help me a
lot!

Thanks,
Nayan

— Nayan Choudhary wrote:

I have a BIG problem. Though I am not doing game programming right
now, I am making an application which loads two HUGE bitmaps (250MB+
each) into memory for some purpose. I am using MFC for developing it.

Do you have any idea how it can be done without taking a lot of time
and lot of memory?? I have 256 MB RAM.

My app was able to load 60 MB bitmap image easily. But images of
sizes 150 MB bug my computer. In future I will be handling images of
size like 2GB or so.

The simplest answer is that you should buy about 3 gigabytes of RAM.

It may be possible to do what you want to do in a smaller amount of
memory. But, fitting 10 kilos of rice into a 1 kilo sack takes a lot of
work. And, it always costs more and takes longer than buying a 10 kilo
bag.

	Bob Pendleton+-----------------------------------+