Vidar is a fairly geeky guy who enjoys writing and using nifty software. He hopes this blog will present new niftyness to you, the adoring fans.
I represent a company for which I do some technical blogging for. I’ve stumbled upon your LINUX ATE MY RAM! page from the social networking sphere, and thought I’d ask permission to blog about this and link to your site.
I’ve encountered newbies hitting the same roadblock, wanted to explain the common misunderstanding and link to your site at the bottom of my blog post.
Is that okay with you?
Absolutely! Anything that increases awareness of the wonders of disk cache has my support.
Hi. Thx for your program : http://www.vidarholen.net/contents/junk/mandel.html
I have tried to run it. After make I have :
gcc -O9 -o mandel mandel.c -lpthread -lm -g -std=c99 -Wall -Werror
cc1: warnings being treated as errors
mandel.c: In function ‘calc_pixel’:
mandel.c:292: error: ‘drgb’ may be used uninitialized in this function
make: *** [mandel] Błąd 1
Can you help with it ?
My gcc 4.3.4-6 from debian doesn’t complain, but yours is right. Try simply editing the makefile and removing the word “-Werror” on line 4. Does that help?
Yes. It works fine. I have AMD turion 64 X2 and Ubuntu 64-bit and 2 GB RAM. What number of threads should I use ?
2 should be fine.
You are right. ( Why you use -j 3 ? ).
I have changed one function
and it works 2 time faster.
Congrats for your blog! I’ve been reading your “linux ate my ram” mini-blog Everythin ok, but I have one question. I have a server with 4GB ram, and memory monitored. I’ve observed that it always have enough memory (+/- buffers/cache line) with some graphs, but there are certain moments that the OS has needed a bit of swapping (only a few megs) but the free memory is always high. I’m pretty sure cause I generate memory graphs, and the amount of free memory is always high. What do you think about it?
The kernel can be configured to swap out unused applications to make room for more disk cache to speed up applications in use. The degree to which this is done is called ‘swappiness’, configurable in /proc/sys/vm/swappiness.
If swappiness is 0, the kernel will never swap out unused apps unless it’s completely out of RAM. If it’s 100, the kernel will frequently swap out unused apps to make room for disk cache to speed up in-use apps.
The default in Ubuntu is 60, so there you will sometimes see some swap use even with plenty of free memory.
Also, once something is swapped, it will just sit there until the memory is modified, freed or something else needs the swap space. This means that trace swap usage can be caused by a short memory spike long ago and/or of short duration (maybe shorter than your logging tool).
This is a sign of Linux’ effectiveness in not wasting work that has gone into writing pages to swap.
Fantastic Vidar. Great explanation
I really like your linux memory caching page and was wondering if I could upload it to and publish it to an internal network? I would of course credit your site.
Sure, anything to spread the page cache love!
I want to ask you if I could translate your linuxatemyram.com site to spanish and post it on a public forum?.
Regards and thank you for your nice explanation.
Sure! Just make sure to link to the original.
The bottom section of http://www.vidarholen.net/contents/junk/nicotine.html contains an error. A cigarette does not contain about 7mg of nicotine, but about 0.7mg; mine contains 0.6mg per cigarette. An aubergine has an average weight of 300g, so one aubergine contains about 30µg nicotine, which is 0.03mg nicotine; 0.6mg / 0.03mg is 20, so 20 aubergines holds the same amount of nicotine, as one of my light cigarettes does.
Congratulations for your https://github.com/koalaman/shellcheck! Is there any way to choose (enable/disable) the checks the shellcheck script will use? Is it possible (easily) to add additional checks if needed?
Thanks in advance,
For the latest, local git version, you can use shellcheck --exclude=SC1234,SC2345 file to exclude certain types of checks.
shellcheck --exclude=SC1234,SC2345 file
Any new checks requires modifying the source code. It’s conceptually very simple, and most of the checks are under 15 lines of code, but it assumes familiarity with Haskell and I’m sure the a lot of the utility functions seem quirky and obscure. If you’d like to try, you can just browse the list of commits and see the diffs for adding new checks.
Thanks for your prompt response Vitar.
I was able to clone, build and execute shellcheck using the exclude option.
Have you already thought in create a SonarQube (http://docs.codehaus.org/display/SONAR/Plugin+Library) plugin for that?
I’m not familiar with SonarQube and I have no plans to integrate directly with it. Maybe you can use ShellCheck’s CheckStyle XML output and SonarQube’s CheckStyle plugin to bridge the gap?
I think you’re slightly wrong on linuxatemyram. There is an indirect claim on the main page, and a pretty direct claim on the play.html page that caches/buffers won’t ever cause an application to swap. This is incorrect though.
Linux will swap out *unused* pages from applications to keep some disk caches alive, if that is possible. The threshold is controlled by the sysctl vm.swappiness. I assume that you cannot see this effect with munch.c, because it is actually active on most of its pages, thus it won’t get swapped.
This gets pretty important on desktop systems. The default of vm.swappiness=60 makes linux to start swapping application data at 40% RAM usage, if it sees it fitting. On desktops, this often means to swap out the file manager or any other currently unused application (web browser, email client…) which has to be swapped in first.
Ignore the following captcha and enter 'bunnies' in the field instead.