3 ms·
> So he's essentially using the OS's disk cache as his cache, and tracking the disk files substituting for manual memory allocation. And that's often not the
by dom0 10y ago
> So he's essentially using the OS's disk cache as his cache, and tracking the disk files substituting for manual memory allocation.
And that's often not the worst idea, because, when done correctly, this stuff never hits the disk when enough RAM is around.
Plus, life cycle management is done by the OS, not by you. It also tends to work better than "not at all" on memory pressure or if there isn't a lot of memory in the first place.
- Filligree 10y agoIf you write a file to disk, then wait fifteen minutes before deleting it, chances are the OS will have flushed it to disk sometime in the meantime. It won't have to re-read it if there's still free memory, but it's extra load on disk io. If you write a lot of them, then even if you have the memory, you may overrun the size limit of the write buffer and cause application stalls. Writing to a ramdisk (e.g. tmpfs) is always an option, though.
- dom0 10y agoEvery OS has flags for this. Windows' CreateFile has a _TEMPORARY flag and most unixes have something like O_TMPFILE.
- barrkel 10y agoIt'll be flushed to disk within seconds. I agree in a memory-rich environment it's far from the worst idea. However now you need to manage the files. You've just pushed the problem somewhere else.
- dom0 10y agoEvery OS has flags for this. Windows' CreateFile has a _TEMPORARY flag and most unixes have something like O_TMPFILE. These avoids flushing them to disk, even on a background writer timeout (Linux/Windows). Further, on many *nix systems /tmp and the like are often in-memory FSes.