Re: physical storage on disk
William wrote:
I need to deal with a huge bitmap(4000*30000, 256color) file. That will be
114MB. I hope the app can be run on a PC with low physical
memory(128MB~256MB) but large free harddisk(more than 40GB).
So, I wonder if it is possible to load the file into disk-memory.
I don't think I really know what you mean what this disk-memory is, nor that
you know how virtual memory works. You might want to read up a bit on that
topic, as it makes it easier to talk about it.
Anyway, what you typically do in cases where a file is too big for holding
it in memory, is that you only load pieces of it into memory on demand.
What William suggested, mapping the file into memory, is typically a good
solution when the size of the file doesn't exceed the virtual address space
(around 2GiB for win32). The OS then loads the pieces into RAM on demand,
i.e. when you access them, and writes them back if you modify them there.
Depending on what you are doing with the bitmap and how the access patterns
are, this might be the easiest way. However, it doesn't have to. If you are
accessing the pixels in the order that they are in memory, the caching
works best. If you run across them, i.e. rowwise instead of columnwise, the
OS has to read a full new page for every pixel! If you are matching one
pixel against the ones surrounding it, the typically best way is to use a
tile-based organisation of the data. There was a thread in
comp.lang.c++.moderated where someone stumbled exactly across this problem,
but I don't remember exactly when.
Uli