Beginner memory question.

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Apr 19 14:46:35 UTC 2022


On Tue, Apr 19, 2022 at 12:54:06PM +0000, bauss via Digitalmars-d-learn wrote:
> On Saturday, 16 April 2022 at 20:48:15 UTC, Adam Ruppe wrote:
> > On Saturday, 16 April 2022 at 20:41:25 UTC, WhatMeWorry wrote:
> > > Is virtual memory entering into the equation?
> > 
> > Probably. Memory allocated doesn't physically exist until written to
> > a lot of the time.
> 
> You can also exceed your RAM in a lot of cases, as the OS will just
> start using your disk for RAM instead, so just because you have 8 GB
> of ram doesn't always mean you can only use 8 GM of RAM (in theory of
> course.)

In practice, having your program use more RAM than you have causes the
OS to start thrashing on I/O as it scrambles to load/unload pages from
the cache as your code accesses that (virtual) memory. Other programs
get swapped out, everything slows down to a crawl, and your harddrive
lifetime decreases by a couple of months (or maybe a year or two).

So yeah, in theory definitely possible (and in fact workable as long as
each individual program's entire working set can fit in RAM at the same
time -- the OS can then swap out the other programs while that one
program runs), but not something you want to push. Performance will slow
down to an unusable crawl, and you may need a hard reboot if you don't
want to spend the rest of the day waiting for the I/O thrashing to catch
up with itself.

Not worth it.


T

-- 
Chance favours the prepared mind. -- Louis Pasteur


More information about the Digitalmars-d-learn mailing list