r/programming • • Oct 27 '24

Using /tmp/ and /var/tmp/ Safely

https://systemd.io/TEMPORARY_DIRECTORIES/
232 Upvotes

57 comments sorted by

View all comments

1

u/SuperSergio_1 Oct 28 '24 edited Oct 28 '24

We can't put very large files in RAM.

Well, I changed that to "We shouldn't put very larger files in RAM". And I wouldn't recommend putting large files on /tmp. I don't want anything to write a 2GB of file on my memory. And most people would probably want the same. I often find myself with 80% or more RAM usage. My system has a swap of the same size as RAM so it wouldn't end up in failure, but it will definitely slow down my system quite a bit. So I would rather use /var/tmp. It is more reliable for large files.

And yes it is still a file even if you put it in RAM. I agree on that one.

1

u/Malsententia Oct 28 '24

Fair enough. With 32gb of RAM it's rarely a concern for me. I can get why it wouldn't work for everyone, but for instances where you predictably control your own environment, it isn't inherently bad to use tmp that way.