4 ms·
Disk cache for one. Disk cache is really flexible at the OS level. Look up 'vmtouch' on Linux and play with some recently used files, you'd be surprised how ma
by AnotherGoodName 4y ago
Disk cache for one.
Disk cache is really flexible at the OS level. Look up 'vmtouch' on Linux and play with some recently used files, you'd be surprised how many are in memory. If you don't have swap and only have 'X' amount of RAM free the program will still load and run fine, it'll just do so in a way that more directly thrashes the disk. If you add some swap the OS will page out some other memory that's not being used giving 'X+Y' RAM free for disk caching that the OS will use.
In fact this usage of free memory as disk cache is so ingrained that memory used this way doesn't even appear allocated. OSes are pretty much all designed to use whatever free RAM is available as disk cache. The disk cache shrinks if that RAM is actually needed.
Effectively a great way to think of swap is that your OS is always swapping, even without a swapfile! If you read a file there's swapping of that file into memory, it's even done using the standard memory paging that swap files do. Without a swap file you still have swapping but you've just removed the ability for the OS to write out memory that it thinks is less relevant than the files you're currently trying to read. Which is almost always a loss.
- lazide 4y agoThat is temporary and evictable kernel memory usage. It also isn’t allocating more memory than it has while doing it, it evicts things when it runs out of unallocated memory. Technically a program, but not what I think anyone typically considers one in this context? What other ones are you aware of? I ask because generally programs use RAM because it’s fast - otherwise they’d use something else. Having a program intentionally allocate more than is available would almost certainly result in serious performance issues it would have a hard time dealing with predictably - as compared to using disk for the ‘excess’, and then reading/loading what it needs.
- AnotherGoodName 4y agoWell simply put any allocation that's not really needed any time soon but is also not freed. Swap let's you use that. In terms of what benefits from that most modern programs are actually surprisingly flexible in memory allocation. Anything with a garbage collection behind the scenes will flush more often if needed. Having swap to push the non needed programs out let's GC based programs keep allocations longer which is intended to enable reuse