• tal@lemmy.today
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    15 hours ago

    I wrote this because my /tmp tmpfs was taking up 32GB of ram despite the files inside summing to only 3MB.

    Note that tmpfs doesn’t force its contents to remain in memory — the kernel can move stuff there to swap space if it needs to do so.

    Ramfs is the filesystem that keeps things locked in memory:

    https://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt

    With ramfs, there is no backing store.  Files written into ramfs allocate
    dentries and page cache as usual, but there's nowhere to write them to.
    This means the pages are never marked clean, so they can't be freed by the
    VM when it's looking to recycle memory.
    

    ramfs and tmpfs:
    ----------------
    
    One downside of ramfs is you can keep writing data into it until you fill
    up all memory, and the VM can't free it because the VM thinks that files
    should get written to backing store (rather than swap space), but ramfs hasn't
    got any backing store.  Because of this, only root (or a trusted user) should
    be allowed write access to a ramfs mount.
    
    A ramfs derivative called tmpfs was created to add size limits, and the ability
    to write the data to swap space.  Normal users can be allowed write access to
    tmpfs mounts.  See Documentation/filesystems/tmpfs.txt for more information.
    
    • Redjard@reddthat.com
      link
      fedilink
      arrow-up
      1
      ·
      23 hours ago

      Maybe. It’s been a while so I don’t know 100% this was put to the test, but I wanna say the system has a weird kernel which leads to it not swapping out tmpfs properly.

      But ordinarily you should be right, this would simply ruin the stats visually until something forced it to swap out, since konsole shouldn’t be accessing it.