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.
When RAM is full, writing to files in /dev/shm will use swap partition?
When RAM is full, writing to files in /dev/shm will use swap partition? My doubt is because when my RAM is life 50% occupied or more, the rest of it is used as cache. So, i am imagining if /dev/shm will still be available - as i want, to potentially occupy RAM + swap-, and not only RAM, if available, although there is much space left in swap.
The ability to use swap is an entire thread worth of variables. Ram is mostly a limited variable. You only have so much. That doesn't mean that when ram is full it will use swap in every instance.
Thank you! My issue was that i did not know (or have forgotten that) /dev/shm is a mounted file system. Now, i have read all this documentation. Much interesting!
"Tmpfs is a file system which keeps all of its files in virtual memory.", the first paragraph, means it will (possibly) use both RAM and swap, right? My mounted one has these options:
Code:
$ mount |grep shm
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
$ df -h|grep shm
tmpfs 7,8G 773M 7,1G 10% /dev/shm
Why the swap size is not counted? There is 16G of each swap and RAM. Cached memory in RAM looks, right now, less than 20% of all RAM.
My computer has much RAM, 16GiB. It gets filled slowly, starting with less than 10% when the computer is booted, and over 70 or 80% after a few days. I have discovered that Firefox and Thunderbird, sometimes (only sometimes) are really hoggers - but this is not deterministic, as i expected: closing their processes and restarting them does not change that much, in the end. I use Vivaldi too, and i have noticed that after sometime i can close it and reopen to get a considerable amount (about 2 or 3GiB, at most, i guess) of RAM freed. But it seems pretty repeatable. The RAM is for tab's dynamic history, i think (if anyone is sure of the reason, please, tell me). All riht, good. But i lost 20 to 70% of the RAM without having any software that can be pointed to have them. I do not know what it can be. To have it free again, only with a reboot, sadly.
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
But i lost 20 to 70% of the RAM without having any software that can be pointed to have them. I do not know what it can be. To have it free again, only with a reboot, sadly.
That is an issue which should be handled. /dev/shm itself is not a problem.
Filling ram up more each day is a problem. You have plenty of ram I'd think.
I agree with you, my RAM amount is big. But it does not fill up quickly. It goes up as i browse several pages with browsers, and a few Firefox profiles opened simultaneously, all the time, and seeing several Thunderbird messages, which is also opened all the time, as time passes. These are the only things i could as point some logical causes to RAM getting almost full. But it really impresses me that a browser will expend more than 1GiB of RAM just because i have several pages (like 10, 20, usually at most these, in each window) opened, and they also remember a limited number of pages navigated in each tab (both Firefox and Vivaldi do this) and some cache, i know. 1GiB of cache?? I do not think, so, for the kind of things i see not reloading when i use back button in the tabs.
it might contain extra options /dev/shm was mounted with - maybe they'll answer your question.
Did you see that i added 'mount' output in the original post, ondoho? I posted another messsage noticing this just to be sure nobody lost that important edit. Or are there more details that mount can give about /dev/shm "disk"?
Again, how do you know your ram is lost?
Did you read the page linked in post #7 (and there is a link to an additional page at the bottom - if you are interested)?
Again, how do you know your ram is lost?
Did you read the page linked in post #7 (and there is a link to an additional page at the bottom - if you are interested)?
I saw that page, and i also saw your post, pan64. I will just make a test to confirm my suspicion to the reason that i lose RAM as time passes. And i will read that page too. I just could not do this as quickly as the answers for the 2 others posts made here, since yesterday. Just wait a bit, i will come back here with more information.
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 forgot to say: i did read carefully the first page you sent, with documentation about tmpfs. In fact, it is still open here. I did not understand everything, mainly in the last parts of it, but i think the general idea and facts are fairly clear to me.
About /dev/shm things being moved to swap or not, my doubt is sort of simple: if RAM is eventually full, and some swap is being used for the OS opened programs, which is normal, will /dev/shm still work? I expect that it will, although its size (as my 'df' output showed above) can be at most ~7,8GiB, which should be half of my RAM memory only (since it would be ~25% of total memory of RAM+swap).
I cannot recover it unless i close all programs (except those which obviously do not spend much RAM) or if the computer reboots.
Right now, i just did a test: i closed all programs which i think that can consume much memory (or think they are consuming more than should, as i said about the browsers), to see how much memory would be freed. The result is close (visually, in the monitoring graph, i did not measure it in numbers) to what is spent after a reboot. After reopening all browsers and a few more "complex" programs, just 31% of the RAM memory is occupied by programs, and 36% used with cache. Shared memory and buffers use use are minimal, as most of the time i have ever seen. I did not remove any file i have stored in /dev/shm, which are 233MiB in total.
While doing the test just mentioned, i have taken some screenshots to register the memory use graph, which i use in my Mate Desktop. They are in the gallery below, and after the link, i make some notes about each image, in order:
1) Usage of RAM before i started writing this post. There is a little drop of free memory in this image just because i closed a few tabs in 2 Vivaldi private windows.
2) A good amount of freed memory after closing Vivaldi.
3) A few more programs closed: Telegram, skype (no login done, in this reboot), Netbeans, Bazaar Explorer, Gimp with a few small images open, and nothing else, if i remember correctly.
4) Thunderbird closed (sometimes this did a big memory free impact, similar to what Vivaldi did here).
5) Firefox with javascript enabled profile. I do not use it as much as Vivaldi or as Firefox profile without javascrip enabled (disabled most most most of the time, i even has an extension to turn it on/off easilier then with about:config thing).
6) Firefox profile with no JS closed. It has 3 windows, with less than 20 tabs used most of the time (the unused tabs kept in them are numerous, but they are not loaded unless i ask to show them, and i never do this much).
7) Here, all programs which i think use much RAM were closed. I left open just Mate terminals opened, and they have limited history set, xpdf with a small document, Pluma (notepad like text editor of Mate) and Caja (Mate file manager) opened. Memory used by program is pretty low, now. Good.
8) Reopened firefox profile with JS disabled.
9) Reopened firefox profile with JS enabled.
10) Most things reopened, except Vivaldi, which was the bigger memory user in this test.
11) Vivaldi reopened (Vivaldi tabs work like Firefox's: they are only reloaded if i click to show them; without it, they are just tabs in the windows).
12) Everything reopened: Telegram, pidgin, Gimp with all the screenshots until 11 opened, Netbeans, with a project opened, Bazaar Explorer, algo with the same project opened.
Right now, i am not sure if, after a reboot this is the amount of RAM that these programs use. But surely the browsers have close to the same amount of tabs opened, compared to what was this, before beginning the test. The only difference here is the private windows. I keep windows and tabs opened in them when i close them and when i reboot. Just private windows/tabs are lost, although i use them considerably.
Now, i will read https://www.linuxatemyram.com/ , which has been waiting. And I also will post here again after rebooting the computer (but this may take a few days, i do not want to reboot just for this), to tell how much memory is spent by all programs, in this situation, considering just the programs i leave constantly open.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.