C++'s standard (and contributed) libraries are fairly
stuffed with good "container classes" that will enable applications to have the
functional illusion of "an unlimited,
n-dimensional storage space within which to work," which some applications do need. But, they do it
efficiently, being extremely mindful of the vagaries of virtual storage ... particularly the fundamental(!) concern of locality of reference.
"Don't fret over
nanoseconds" here. There is no price-to-be-paid by slightly longer code paths taking a few billionths of a second more. No, the
real price is measured in "multiple
milliseconds," and they occur with every page fault.
Uncontrolled, or simply unplanned-for, page fault activity is rudely called,
"thrashing." Or, as I used to say back in the days when a 20-megabyte disk drive was about the size of an apartment's washing-machine, "MaytagŪ Mode." We
literally had one of those devices slowly juggle itself to the very edge of the raised floor, over in the corner where a few tiles were removed, and ...
(The spinning disk broke loose from the capstan and very nearly went sailing out across the machine room.)
The performance-degradation curve caused by thrashing is variously called "elbow-shaped" or simply, "hitting the wall." It basically goes
straight to Hell straight up,
exponentially. Poorly designed applications which need lots of RAM are especially vulnerable to it, the moment they come out of the memory-rich "developer's environment" and an attempt is made to deploy them to production.