Outils pour utilisateurs

Outils du site


issue130:labolinux1

Ceci est une ancienne révision du document !


Table des matières

1

Last month, I retweeted a link to an It’s FOSS article by Abhishek Prakash on How Much Swap Should You Use in Linux? https://itsfoss.com/swap-size/ The short answer put forth in the article was “it depends on a number of factors.” This article got me wondering about how much RAM and swap would I use on an average day at work? A few details about my work machine: Intel Core i7-3770 @ 3.9GHz, 28GB RAM, Intel 530 180GB SSD + Seagate ST1000DM003 1TB hard drive. For the test, I ran Linux Mint Cinnamon 18.3 – with the latest updates. I started by rebooting the machine to eliminate anything that might be running in memory. At the LightDM login prompt, I switched to a virtual terminal and ran cat /proc/meminfo, the result was: MemFree 28,225,148 kB SwapFree 23,999,484 kB

Le mois dernier, j'ai retweeté un lien vers un article d'Abhishek Prakash dans It's FOSS sur Combien de swap faut-il utiliser sous Linux ? https://itsfoss.com/swap-size/ La réponse courte donnée dans l'article était « cela dépend de nombreux facteurs ».

L'article m'a fait songer à la quantité de RAM et de swap que j'utilisais pendant une journée normale au bureau. Voici quelques détails concernant ma machine au boulot : Intel Core i7-3770 @ 3,9 GHz, 28 Go RAM, SSD Intel 530 de 180 Go + un disque dur Seagate ST1000DM003 de 1 To.

J'ai choisi Linux Mint Cinnamon 18.3 avec les dernières mises à jour pour le test. J'ai commencé par redémarrer la machine afin d'éliminer tout ce qui tournait dans la RAM. À l'invite de connexion LightDM, j'ai basculé sur un terminal virtuel pour lancer cat /proc/meminfo. En voici le résultat :

MemFree 28,225,148 kB SwapFree 23,999,484 kB

2

Before going further, it’s worth mentioning that at no time during the testing did SwapFree ever change. This seems to confirm Abhishek’s theory that, with a lot of RAM, you might not ever touch swap space. I started by logging in and loading the Cinnamon desktop. I had my phone connected to my PC in charging mode (since boot), but nothing else was running. I ran the same cat /proc/meminfo. The result was: MemFree 27,752,840 kB Just over 472,308 kB difference. Firefox is undoubtedly one of the most used applications on Ubuntu, so I started by launching it. I’d heard in the past that Firefox tends to “leak” RAM. With Firefox launched and sitting at the default page, RAM usage was as follows: 3,MemFree 27,18420 kB

Avant de continuer, cela vaut le coup de noter que SwapFree n'a changé à aucun moment du test. Ceci semble confirmer la théorie d'Abhishek que, avec beaucoup de RAM, vous pourriez ne jamais toucher à l'espace swap/

J'ai commencé par me connecter, puis charger le bureau Cinnamon. Depuis le démarrage, mon téléphone était connecté au PC en mode Charger uniquement, mais rien d'autre s'exécutait. J'ai lancé le même cat /proc/meminfo et le résultat était

MemFree 27,752,840 kB

Un peu plus de 472.308 kB de différence. Firefox est, sans aucun doute, l'une des applications les plus utilisées sous Ubuntu ; aussi, j'ai commencé par le lancer. J'avais déjà entendu que Firefox a tendance à faire fuiter le RAM. Firefox étant lancé, mais resté sur sa page par défaut, l'usage de la RAM était :

MemFree 27,183,420 kB

3

This is a 1,041,728 kB difference. On a system with 28GB of RAM, this difference is barely noticable, but on a system with only 2GB of RAM, the RAM available to the rest of the applications and operating system is already significantly reduced. Keeping in mind that a little less than half of that number is the Cinnamon desktop, it’s an argument for using a lighter-weight desktop like LXDE, iceWM, or Enlightenment - at least on older hardware. It also illustrates the fact that modern applications simply need a bit more RAM. Of course no one opens Firefox and just lets it sit at the home page. I opened 5 tabs with the following web pages: my own blog (some photos, no videos), the Full Circle Magazine website, Slashdot (remember when that was a thing), Distrowatch, and OMG Ubuntu UK. Memory usage was as follows: MemFree 26,620,820 Keep in mind that, at this point, there are no other desktop applications open, only Firefox with 5 tabs. Memory usage ran up to 1,604,328 kB or 562,600 kB more than a single tab opened. It occurred to me, while opening all the tabs, that some websites have a lot more content than others: Yahoo, for example, tends to have a lot of ads and Javascript. I closed all the tabs and opened only Yahoo. It took almost a minute of waiting on a fast connection before the Yahoo page completely loaded (all scripts). The amount of RAM required just to load Yahoo alone is a bit astonishing: MemFree 26,736,172 kB In other words, Yahoo by itself takes 447,248 kB, roughly the equivalent of 3-4 tabs. I picked Yahoo on purpose because I see a lot of people using Yahoo as a starting page (or for email). I’m not sure why people pick such a heavy site as a home page in this day and age, but it still seems to be relevant for some people.

4

Earlier in the article, I mentioned that I had heard Firefox “leaks” memory. It seems reasonable to assume that all the RAM doesn’t get flushed when you simply close an application. On closing Firefox the amount of RAM available was: MemFree 27,452,500 When I first logged in to Cinnamon, the memory free was 27,752,840 kB. Loading Firefox with several pages, then closing it, seems to have eaten an extra 300,340 kB, confirming that yes, applications seem to eat a bit more RAM even when they’re closed. I confirmed no Firefox processes were running by running ps aux | grep firefox. The result was my own grep session, no instances of Firefox loaded. So what about that other magical browser from Google: Google Chrome? Google Chrome (not Chromium) took up a bit more RAM than Firefox. The cat /proc/meminfo result was: MemFree 27,024,536 kB I figured some might argue the point that other applications had already been loaded into RAM and this RAM was being used still by the residue of those applications so I rebooted the system once more, opened a virtual terminal, and ran cat /proc/meminfo once more. This time (before logging in to Cinnamon) the memory usage was slightly less: MemFree 28,232,364 kB

5

I loaded up Google Chrome to the default page and ran cat /proc/meminfo again and got: MemFree 27,324,268 kB Indeed Google Chrome seems to be a bit lighter on memory usage (than Firefox), coming in at 908,096 kB with the default site opened. Before I rebooted and tested Chrome, I decided to test memory usage with multiple applications opened. I opened Firefox to the Full Circle Magazine website. I then opened the Mint Software Manager, the Nemo file manager, the Background (wallpaper) application, GIMP (with a screenshot I’d previously captured), and set VLC to stream an Internet radio station. With all these applications opened, I switched to the virtual terminal and ran cat /proc/meminfo. The result was: MemFree 25,353,268 kB On a machine with only 2GB of RAM, we would be well into the land of swap (2,871,800 kB), but, on this work machine, the RAM usage barely registers a blip. I closed all applications except VLC (which was still streaming audio) and memory usage dropped: MemFree 26,392,388 kB

6

At this point, I wondered if the issue was VLC or whether it was all remnants of Firefox and the other applications? And if it was these other applications, how could I “flush” the RAM without restarting (either Linux or the Cinnamon desktop)? I found an article on Techmint on How to Clear RAM Memory Cache, Buffer and Swap Space on Linux at https://www.tecmint.com/clear-ram-memory-cache-buffer-and-swap-space-on-linux/. The Techmint article outlines the way to clear PageCache, dentries, and inodes, and all three together, but it doesn’t really outline what dentries and inodes are, though it does warn not to clear dentries and inodes on a production server. To clear only PageCache, the article suggests running (as root): sync; echo 1 > /proc/sys/vm/drop_cache

7

It’s worth mentioning that I tried running this command using sudo and it didn’t work, you must actually log in as the root user, which you can do by typing: sudo su - After running ‘sudo su -’, and entering in your password (as long as you belong to the group that can use sudo), you’ll see the root prompt. From the root prompt, the ‘sync; echo’ command appears to work. Because I wasn’t running any kind of production server or anything critical, I ran the command to flush all three items: PageCache, dentries and inodes: sync; echo 3 > /proc/sys/vm/drop_cache Again a warning not to run it on a production server. For a better outline of what dentries are, check our Bruce Fields’ Virtual File System article here: http://www.fieldses.org/~bfields/kernel/vfs.txt At this point, I still had VLC streaming the same radio station. The freed up memory result was surprising: MemFree 27,475,792 kB

8

It’s a bit more memory used than when we first logged into the Cinnamon desktop, but it does appear to free up a significant amount of memory (1,083,404 kB). This seems to indicate that VLC was using just 277,048 kB more RAM than when we first logged in. VLC continued to stream in the background while I checked the RAM usage. What does this all mean? It seems to mean that applications do “leak” RAM, and, even if you’ve closed an application completely, there may still be some residual RAM usage. When using a web browser, it’s much like using any other application that loads a lot of data; a single large file, or web page, may use up a lot of RAM compared to many smaller pages/files. While we all love the mantra of reuse before recycle, old computers with 2GB or less RAM might struggle when used for even light surfing if you surf large sites with lots of content, or open multiple tabs - 4GB of RAM really starts looking like a minimum even for basic web surfing. Lastly, if you are stuck using a system with a small amount of RAM for surfing, you can clear up some of that leaked RAM by clearing the PageCache, dentries and inodes cache.

9

Links of Interest: Bruce Fields’ Virtual File System article: http://www.fieldses.org/~bfields/kernel/vfs.txt Techmint - How to Clear RAM Memory Cache, Buffer and Swap Space on Linux: https://www.tecmint.com/clear-ram-memory-cache-buffer-and-swap-space-on-linux/ It’s FOSS - How Much Swap Should You Use in Linux? https://itsfoss.com/swap-size/

issue130/labolinux1.1519815652.txt.gz · Dernière modification : 2018/02/28 12:00 de auntiee