View Single Post
Old 2021-09-27, 03:39   #5
retina's Avatar
"The unspeakable one"
Jun 2006
My evil lair

2×23×137 Posts

Originally Posted by preda View Post
In my understanding, VIRT in "top" for a process indicates "virtual" memory that is not mapped to physical memory. That would happen for example after a malloc() but before writing anything to the malloc'ed range. And RES is memory mapped to physical pages. Thus, VIRT is limited by the virtual address range (huge), not by the physical memory or swap.
Yeah, that is basically correct. I've seen processes have TiB of VIRT without any issue. It can be safely ignored. But RES, that's where the action happens. You can freely allocate PiB of memory (so I have read, not tried it myself) and all is well until you try to actually use too much of it.

ETA: Linux allocations are equivalent to Windows with the MEM_RESERVE flag set, and the MEM_COMMIT flag unset. With the difference being Linux auto-commits, whereas Windows will GPF upon access.
Originally Posted by preda View Post
OTOH it's a good idea to have a swap set up, in order for it to collect the "dead" regions of allocated memory (freeing the physical memory from junk). Creating the swap does not require a swap *partition*, can be done in a file using "mkswap" and "swapon".
IMO swap is of no value if you have nowhere to swap to.

And IMO also swap is of no value even when there is somewhere to swap to, just buy more RAM. YMMV :P

Last fiddled with by retina on 2021-09-27 at 03:46 Reason: Add Windows equivalence
retina is online now   Reply With Quote