LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 02-23-2021, 04:42 PM   #1
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Rep: Reputation: 51
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.
 
Old 02-23-2021, 04:55 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,130

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
When in doubt read the documentation - here.
 
1 members found this post helpful.
Old 02-23-2021, 05:06 PM   #3
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,987

Rep: Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628
/dev/shm is really a sort of cache that programs use to swap information between. It isn't really the same as swap. It is a ramdrive area. It will consume ram.
https://www.cyberciti.biz/tips/what-...cal-usage.html
https://superuser.com/questions/4534...ilitates%20IPC.
https://www.kernel.org/doc/gorman/ht...rstand015.html



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.
 
1 members found this post helpful.
Old 02-23-2021, 06:08 PM   #4
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
besides mount command, now i show the output of 'df -h' command

Quote:
Originally Posted by syg00 View Post
When in doubt read the documentation - here.
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.

Last edited by dedec0; 02-23-2021 at 06:28 PM.
 
Old 02-23-2021, 06:28 PM   #5
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
Previous post edited.
 
Old 02-23-2021, 07:03 PM   #6
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,987

Rep: Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628
virtual memory is not swap usually. It is ram.

Filling ram up more each day is a problem. You have plenty of ram I'd think.
 
Old 02-23-2021, 08:32 PM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,130

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
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
 
1 members found this post helpful.
Old 02-24-2021, 02:38 AM   #8
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Look at the oputput of
Code:
mount
it might contain extra options /dev/shm was mounted with - maybe they'll answer your question.
 
Old 02-24-2021, 05:30 AM   #9
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,876

Rep: Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315
Quote:
Originally Posted by dedec0 View Post
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.

how do you know your RAM is lost?
 
Old 02-24-2021, 10:35 AM   #10
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by jefro View Post
virtual memory is not swap usually. It is ram.

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.
 
Old 02-24-2021, 10:38 AM   #11
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by ondoho View Post
Look at the oputput of
Code:
mount
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"?
 
Old 02-24-2021, 10:40 AM   #12
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,876

Rep: Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315
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)?
 
Old 02-24-2021, 11:04 AM   #13
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by pan64 View Post
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.
 
Old 02-24-2021, 11:33 AM   #14
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
Lightbulb

Quote:
Originally Posted by syg00 View Post
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).
 
Old 02-24-2021, 03:18 PM   #15
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
Post

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:

http://imgbox.com/g/1giMPNAXQV

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.
 
  


Reply

Tags
/dev/shm, ram, swap



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
differences betwne /dev/shm and kernel.shm hallask Linux - Server 2 09-23-2011 06:26 AM
/dev/shm not mounted /dev busy compgenius999 Linux - Newbie 1 03-03-2010 11:12 AM
Sizes of /dev /dev/shm /lib/init/rw jmoschetti45 Linux - Server 0 01-25-2010 11:20 AM
What is /dev/pts, /dev/shm? mrpc_cambodia Red Hat 1 10-18-2004 03:27 AM
RAM DISK /dev/shm RH 7.2 . Why? peter_robb Linux - Software 0 02-06-2002 08:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration