Re: Using virtual memory and/or disk to save reduce memory footprint
On Mar 5, 3:20 am, Jeff Schwab <j...@schwabcenter.com> wrote:
nick wrote:
I am writing a C++ GUI tool. I sometimes run out of memory
(exceed the 2GB limit) on a 32bit Linux machine.
What 2GB limit? Do you mean that the machine only has 2GB of
RAM? Or do you mean that you're exceeding the 3 or 4 GB limit
on address space?
I was wondering about that myself. I've had programs on a 32
bit Linux that used well over 3 MB.
I have optimized my GUI's database a lot (and still working
on it) to reduce the runtime memory footprint.
I was thinking of ways to off-load part of the database to
virtual memory or disk and reading it back in when required.
The kernel already does that for you, automatically. Doing it manually
is called "overlaying."
http://en.wikipedia.org/wiki/Overlay_(programming)
The kernel can only do it when the entire image would fit into
the virtual address space (4 MB under 32 bit Linux).
"Overlaying" will allow a lot more. And it's only called
overlaying when you swap in and out code and named variables; if
you're just buffering data, the name doesn't apply. (As an
extreme example, programs like grep or sed easily work on data
sets that are in the Gigabyte range or larger; they only hold a
single line in memory at a time, however. And I'm sure you
wouldn't call this overlaying.)
FWIW: I don't think that the Linux linker supports overlay
generation, at least in the sense I knew it 25 or 30 years ago.
(Although explicitly load and unload dynamic objects, that
probably comes out to the same thing.)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34