TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Linux ate my RAM

194 pointsby wallzzover 11 years ago

28 comments

makomkover 11 years ago
This is actually wrong. For some reason (probably because of the way it&#x27;s implemented internally) Linux includes shared memory allocations in the &quot;cached&quot; figure. If you calculate the amount of free memory using &quot;free -m&quot; in the way this web page advises, you&#x27;ll think that memory is free when it really isn&#x27;t - unlike true cache, shared memory cannot be discarded when the space is needed for something else.<p>I&#x27;ve actually had buggy desktop applications use several gigabytes of RAM as shared memory, so this can make a big difference.
评论 #6711544 未加载
评论 #6711950 未加载
评论 #6711280 未加载
评论 #6713578 未加载
jared314over 11 years ago
Previous Discussions:<p><a href="https://news.ycombinator.com/item?id=3698652" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=3698652</a> (1 year ago)<p><a href="https://news.ycombinator.com/item?id=6368562" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=6368562</a> (2 months ago)<p><a href="https://news.ycombinator.com/item?id=1831322" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=1831322</a> (3 years ago, no comments)
bediger4000over 11 years ago
How bizarre. In the 1993-94 time frame, one of the big talking points about Windows NT was that it was the only OS with an integrated file system cache. That wasn&#x27;t true even at that time, as Solaris also had such a cache, but such is the nature of propaganda.<p>I&#x27;m tickled that what once was a big &quot;technical&quot; advantage becomes a major source of confusion. Presumably, OSes of Windows NT heritage have retained file system caching, which offers a huge performance benefit. Why don&#x27;t Windows users have confusion over this issue? Doesn&#x27;t Windows offer an easy way to check or is the whole thing presented clearly, or is Windows so complicated not many people get this far?<p>I&#x27;ll also draw a parallel to DUI - without a breath-o-meter, DUI is a lot like driving while distracted. It&#x27;s impossible to quantify, and therefore not that much of a crime. With a breath-o-meter, or with &quot;top&quot;, it&#x27;s possible to put a number on drunkeness or lack of free memory, and the whole thing becomes a problem.
评论 #6712094 未加载
评论 #6712359 未加载
评论 #6711982 未加载
评论 #6712006 未加载
rdtscover 11 years ago
A quick practical answer is to use htop and look at the memory bar.<p>* Green = resident memory used (probably what you want most of the time)<p>* Blue = buffers<p>* Yellow = cache
评论 #6714109 未加载
评论 #6713257 未加载
评论 #6728549 未加载
hippichover 11 years ago
That&#x27;s how I check true free memory available:<p><pre><code> root@joe-pc:~# free -m total used free shared buffers cached Mem: 32057 30347 1710 0 1312 21568 -&#x2F;+ buffers&#x2F;cache: 7466 24591 Swap: 0 0 0 root@joe-pc:~# sync; echo 3 &gt; &#x2F;proc&#x2F;sys&#x2F;vm&#x2F;drop_caches root@joe-pc:~# free -m total used free shared buffers cached Mem: 32057 5628 26429 0 4 891 -&#x2F;+ buffers&#x2F;cache: 4732 27325 Swap: 0 0 0 root@joe-pc:~#</code></pre>
评论 #6715466 未加载
pearjuiceover 11 years ago
Then you should <a href="http://downloadmoreram.com" rel="nofollow">http:&#x2F;&#x2F;downloadmoreram.com</a>
评论 #6714492 未加载
评论 #6711716 未加载
评论 #6712424 未加载
评论 #6712596 未加载
daGrevisover 11 years ago
The page seems to be down.<p>Here&#x27;s how it looked: <a href="http://web.archive.org/web/20131011053519/http://www.linuxatemyram.com/" rel="nofollow">http:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20131011053519&#x2F;http:&#x2F;&#x2F;www.linuxat...</a>
nlyover 11 years ago
Forget the kernel, someone really needs to do chromeatemyram.com
andmariosover 11 years ago
This is the worst piece of Linux advice ever. I use Linux for many years and every time I had a memory leak or a process using too much memory, every google search about the problem would lead to some &quot;guru&quot; giving this advice.<p>This explanation which has been replicated thousands of times on every linux forum on the planet, prevents people from solving real problems. It started as a useful piece of information but nowadays it is spam.
评论 #6712288 未加载
评论 #6725317 未加载
cawover 11 years ago
Wow, I can&#x27;t believe how many times I&#x27;ve had to explain this to people as they log on to shared VNC servers. &quot;I thought this had 16G of RAM free, I asked for a 16G machine!&quot;. &quot;It does, stop trying to read top!&quot;<p>Now I&#x27;ll just point them to this website.
jbogpover 11 years ago
Also HN ate your server apparently.
FlyingAvatarover 11 years ago
I hate the invention of &quot;burstable&quot; RAM on VPSes for this reason. Eventually your IO cache grows until it has most of your guaranteed RAM. Now every new process is playing a game of Russian roulette with your hypervisor to see if it can actually allocate into your &quot;burstable&quot; RAM what the kernel is reporting is freely available.
评论 #6712795 未加载
v-yadliover 11 years ago
<a href="https://www.kernel.org/doc/Documentation/sysctl/vm.txt" rel="nofollow">https:&#x2F;&#x2F;www.kernel.org&#x2F;doc&#x2F;Documentation&#x2F;sysctl&#x2F;vm.txt</a><p>You can drop cache by sending a byte into drop_cache.
评论 #6713376 未加载
nraynaudover 11 years ago
that&#x27;s funny, like avery complex or &quot;smart&quot; algorithm, if it works it&#x27;s cool, but when something doesn&#x27;t work, it makes it very hard to pinpoint a culprit.<p>I&#x27;m more and more inclined to either use stupider algorithm that at least I can explain to the user, incremental stuff where they can check intermediate results or taking into account the fact that this algorithm has to be conveyed to users in one way or another since inception.<p>I guess in this case a measure of the swap activity would be a good indicator that the current limiting factor is the RAM, but it also has to be credible. Somehow having 16G written on the box of the ram and 7G written in the &quot;available ram&quot; of a software makes everything more credible that saying &quot;I have a pressure of 1.5madeupunit on the ram front&quot;. Human factors, again.
评论 #6712496 未加载
fit2ruleover 11 years ago
Another thing, you know how sometimes a USB stick needs some time to un-mount? This non-sync&#x27;ed data (say, a copy of a big file) eventually has to be written to the physical disk, and through the little pipe, takes time. Find out how much of this &quot;dirty&quot; buffer you have yet to physically write to the device, while giving the kernel &#x27;hints&#x27; to sync the dirty blocks quickly, with:<p><pre><code> while true; do sync &amp;&amp; grep Dirty &#x2F;proc&#x2F;meminfo; done </code></pre> Lots of gold to be mined from &#x2F;proc&#x2F;meminfo .. bonus points for wiring it up to gnuplot so you can get a real picture of the dynamics of the Linux kernel .. ! :)
评论 #6714851 未加载
Morgawrover 11 years ago
Best way to check how much ram is actually free is to use a higher level tool like a task manager (from various DEs) or a command line tool like htop, they report the actual memory usage of processes
richoover 11 years ago
Not strictly accurate, in the &quot;Why would you want to do this&quot; regard.<p>Ages ago I was hacking linux onto an ARM soc that claimed to have memory it didn&#x27;t (it wasn&#x27;t aware of the display&#x27;s DMA segment). It was near the top of the address space, so generally speaking it didn&#x27;t cause too many problems, but until I could debug it I needed to keep memory usage low, wchih meant disabling the disk cache. What a shitshow that was :&#x2F;
dmouratiover 11 years ago
I always run Ganglia on my servers. You can see memory used, memory shared, memory cached, memory buffered, and memory swapped all over time as well as total in-core memory. This has saved me (and my team) from ever having to misinterpret command line output. Takeaway, Linux is smart about using memory, probably smarter than you. <a href="http://ganglia.sourceforge.net/" rel="nofollow">http:&#x2F;&#x2F;ganglia.sourceforge.net&#x2F;</a>
Sami_Lehtinenover 11 years ago
I think it&#x27;s still disinformative. Disk cache also uses RAM which is allocted and reserved by applications, of course data is swapped out in this situation. o you&#x27;ll need more swap, but it isn&#x27;t a bad thing at all. Even OS&#x2F;2 did this a long time ago, nothing new at all.
jvdhover 11 years ago
So basically this is the inverse of swap. Using memory to make disk reads&#x2F;writes faster, instead of using disk to make more memory.<p>If Linux is consistently doing this, why would you still need a swap partition?
评论 #6713088 未加载
评论 #6713156 未加载
评论 #6713139 未加载
评论 #6713683 未加载
Damogran6over 11 years ago
FWIW, it&#x27;s relevant to OS X too (even Mavericks)...&#x27;sudo purge&#x27; will reclaim some of the resources.
评论 #6711351 未加载
tallesover 11 years ago
Or you can just <a href="http://downloadmoreram.com/" rel="nofollow">http:&#x2F;&#x2F;downloadmoreram.com&#x2F;</a><p>(joke)
usamecover 11 years ago
Ehm. But sometimes stupid linux kernel prefers moving something usefull to swap and caching some shit instead of keeping stuff in ram and not doing caching.<p>So linux sometimes eats your RAM (but in different way).
评论 #6713474 未加载
xacaxuluover 11 years ago
I just love the website design :-) It makes me happy.
AsymetricComover 11 years ago
ITT tech startups learn about Lunix.
jherikoover 11 years ago
right. so there is a bug in linux. gotcha.
评论 #6711920 未加载
评论 #6711380 未加载
评论 #6711467 未加载
评论 #6713770 未加载
jaseemabidover 11 years ago
Lovely! This domain could iframe that SO question :)
评论 #6711144 未加载
free652over 11 years ago
Windows loves to cache and &quot;prefetch&quot; apps, I still need to figure out how to disable prefetching since I have a very fast SSD.
评论 #6711409 未加载
评论 #6711326 未加载
评论 #6711322 未加载
评论 #6711942 未加载