Re: Memory issue
"Alf P. Steinbach" <alfps@start.no>
You set the swap file size to 0 and there is no swap, ever.
First, very few would use a program that modified the system page file
settings just to simplify its own internal memory handling.
Err, I did not mean the program, I meant YOU. :) The user or admin of the
machine. A program certainly has no business with swap or the memory or
anything.
Second, there's no way to do it in standard C++.
Third, the context wasn't about how to turn page file usage off, it was
about what happens on a system with enough memory but page file usage
enabled.
Possibly I misread, the context I was aware of was what happens when memory
is exhausted. As it seen from a C++ program's perspective, that just keeps
adding items to a vector, and see what eventually happens.
You claimed that the system will most likely crawl before anything else is
observed. I didn;t notice anyone injected a restriction of the system to
include a swap configured way beyond physical memory, and the physical
memory set way lower than the process' address limit.
On a machine that has 2G or 4G ram, it is a reasonable setting. (I
definitely use such configurarion with windows, and only add swap after
there is a clear reason...)
Adding so much swap to gain your crawl effect is practical for what?
I'm sorry but that's a meaningless question, incorporating three false
assumptions.
First, not all systems have enough physical RAM to turn off use of page
file, even if a program could recommend to the user that he/she do that,
so this assumption is false.
A machine that fits the "On a machine that has 2G or 4G ram" we can
certainly assume that much ram. :) The interesting question is then only
what is the usual work's memory footprint to make a fair recommendation.
There wasn't either a claim or assumption that every possible case is
covered by that.
Second, right now we're at a special moment in time where on most PCs the
physical RAM size matches the address space size available to and used by
most programs. But as you note below, "bloatware is like gas, fills every
cubic bit of space". It's also known as Wirth's law. And it means that in
a few years we'll be back at the usual usual where the processes running
in total use far, far more virtual memory than there is physical RAM.
The machines with much RAM will ikely use 64 bit OS, so the address space
thing will be gone. Then we'll be back to similar situation we had 5-10
years ago, the 2G limit was above the sky, yet the normal configs did not
set arbitrary amount of swap -- just the practical 2-3x physical size, where
reaching the limit, if happened once in a while still had the machine
responsive to at least kill something. :)
As tracking the memory usage req is not hard, people working with hungry
apps certainly bought the next moodule -- and the next motherboard when
reaching a limit there -- VM is only good is used lightly, with regular
overreach the price on time and nerves exceeds that of the hardware.
So the crawl effect is what is observed in general, and it does not belong
to any particular person, so also this assumption is false.
Third, the assumption that most or all PCs are configured with use of page
file turned off, so that one would actively have to turn it on, is also
false.
I did not claim or assume that either -- the default install of win does set
up some swap, so not-caring users probably live with that. It does not mean
it is good for the majority -- or even a reasonable amount of situations.
Those who care about their system's performance shall do massive amount of
configuration on win and keep vigilance up, as most every program you
install nowadays drops a resident update/remind/nag/whatever deamon.
Linux. google for memory overcommit. (or there is good description in
Exceprional C++ Style). It is exactly as nasty as it sounds -- OS just
gives you address space, and running out of pages you get shot on ANY
access. There is no way to write a conforming C++ implementatuion for
such environment. :(
In summary, standard C++ memory exhaustion detection is unreliable on
Linux and in general unreliable on Windows. ;-)
well, you can put it that way ;-/