When RAM is full, writing to files in /dev/shm will use swap partition?
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How tmpfs is sized is covered in the link I gave. When/wether it will be moved to swap is impossible to predict in advance.
Memory management is much more complicated than you can imagine. A good start for a simple explanation is linuxatemyram
I have read this page, now. Very good information, thank you. I also read the play page linked in the end of it.
Now, i can say clearly to all of you: i was not counfounding cached memory with used memory, in my original question. So, i still have the doubt: if RAM memory is completely used by programs, will /dev/shm space still exist and work? I guess it must be counted as what is used by programs, in the total of RAM + swap size - right?
A request by /dev/shm for memory will be handled just like a memory allocation request by any other program. If sufficient free RAM is not currently available, the request will be satisfied by one of the following (roughly in order):
Discarding cached pages,
Flushing buffers,
Moving pages out to swap space,
Discarding pure text pages (which can always be reloaded from disk).
And of course there is the last resort of the OOM killer terminating processes.
The point is that there is nothing special about a tmpfs wanting memory vs. any other memory request by a program. A tmpfs has a size limit (which defaults to 50% of the system's physical RAM), just as programs have a maximum size (set by ulimit),
A request by /dev/shm for memory will be handled just like a memory allocation request by any other program. If sufficient free RAM is not currently available, the request will be satisfied by one of the following (roughly in order):
Discarding cached pages,
Flushing buffers,
Moving pages out to swap space,
Discarding pure text pages (which can always be reloaded from disk).
And of course there is the last resort of the OOM killer terminating processes.
The point is that there is nothing special about a tmpfs wanting memory vs. any other memory request by a program. A tmpfs has a size limit (which defaults to 50% of the system's physical RAM), just as programs have a maximum size (set by ulimit),
However, it seems odd to have your memory climbing day by day.
Yes, it seems very strange. I do not like it, but my computer reboots in a fair frequency by blackouts, which are not really uncommon where i live. So, extending my test to memory occupied until, for example, 100% RAM + 50% swap are full, after more days of use, is not possible. So, pointing the fault is harder - unless i buy a no break. Testing the memory with linuxatemyram.com little programs is possible, but it will not solve my problem to find the memory hole, if this is the case (remember, i will still check the amount of memory after a clean boot, and after opening everything in this moment).
Anyway, my main doubt with this thread was how /dev/shm requests would be handled when RAM is full, and rknichols clarified it very well, now. For other things, the thread is still open, but i will mark it solved.
Experimenting with how much my used memory would grow, i stopped restarting Vivaldi, which behaves better than Firefox and Thunderbird, for its predictability in memory usage. Right now, according to Mate's system monitor graphics (shown in screenshots above), 90% of RAM is used by programs, and 50% as cache. Curiously, to me, 90%+50% = 140%... strange? Further, today, my computer started to using some swap. 9% of swap is being used, at this moment. I wonder if swap will get direct cuts when i close Vivaldi, and maybe Firefox too, to check how much memory will be recovered.
But i imagine that swap can be left there as is, if it is made of things not much accessed. Or not? Will it be moved to free RAM without its data being accessed?
Further, today, my computer started to using some swap. 9% of swap is being used, at this moment. I wonder if swap will get direct cuts when i close Vivaldi, and maybe Firefox too, to check how much memory will be recovered.
The pages currently in swap will probably stay there. Those will be mostly pages that were needed when various long-running programs and daemons started up, and were never referenced again.
Quote:
But i imagine that swap can be left there as is, if it is made of things not much accessed. Or not? Will it be moved to free RAM without its data being accessed?
No. Why would you want unreferenced pages occupying physical RAM?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.