Live data from Hacker News

Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?

linuxatemyram.com

21–30 of 74 posts

Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?

#21
This is misleading, as the kernel will often swap out processes rather than shrink the disk cache. Its tendency to do this is controlled by the vm.swappiness parameter, which by default heavily favors swapping: http://kerneltrap.org/node/3000

Decreasing this value will favor reducing the cache size and will tend to increase responsiveness. You can set it in the /etc/sysctl.conf file. Low values (≤ 5) are especially good for SSDs where you want to minimize swap usage.

Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?

#22
post #10
post #4

So basically the same thing Vista was doing (prefetch, and admittedly it did a shitty job with >1GB ram), except since its Linux, Oh its all fine guys, we won't destroy the OS' reputation.

Linux has been doing this for a lot longer than Windows has. (Which I only actually know because there was so much FUD about Vista's pre-fetching when it came out.) edit: Sorry, getting prefetching and SuperFetch confused.

MS shipped SMARTDRV with DOS 4.01, which shipped in 1989. By my reckoning, Windows (running on DOS) has had disk caching since before Linux existed.

Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?

#23
post #12

Earlier quoted context omitted.

The Windows task manager has a separate field called "Available". Right now I have 8190 MB total, 3627 cached, 4151 Available, and 537 free (not sure if that adds up perfectly, it was changing while I typed it).

OSX's activity monitor does something similar, it has 4 statuses: Wired, Active, Inactive and Free. Wired and Active are basically the RAM being used (Wired is a special activity status for stuff which can not be moved to disk), Inactive is the cache (generally programs which were used recently) and Free is… well, free. When checking used/free, Inactive and Free count towards free, Wired and Active towards used (thou…

If you really want the details on OS X, see http://developer.apple.com/mac/library/documentation/Perform... and http://developer.apple.com/library/mac/#documentation/Darwin...

See http://www.usenix.org/event/usenix2000/freenix/full_papers/s... for information about the BSD unified buffer cache.

And see http://www.westnet.com/~gsmith/content/linux-pdflush.htm for information about the Linux page cache.

Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?

#24
post #12

Earlier quoted context omitted.

The Windows task manager has a separate field called "Available". Right now I have 8190 MB total, 3627 cached, 4151 Available, and 537 free (not sure if that adds up perfectly, it was changing while I typed it).

OSX's activity monitor does something similar, it has 4 statuses: Wired, Active, Inactive and Free. Wired and Active are basically the RAM being used (Wired is a special activity status for stuff which can not be moved to disk), Inactive is the cache (generally programs which were used recently) and Free is… well, free. When checking used/free, Inactive and Free count towards free, Wired and Active towards used (thou…

He probably has 8GB of RAM (8192MB); some may be lost to address space holes. I have 12GB, if you're finding that implausible.

Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?

#25

This is misleading, as the kernel will often swap out processes rather than shrink the disk cache. Its tendency to do this is controlled by the vm.swappiness parameter, which by default heavily favors swapping: http://kerneltrap.org/node/3000 Decreasing this value will favor reducing the cache size and will tend to increase responsiveness. You can set it in the /etc/sysctl.conf file. Low values (≤ 5) are especially g…

The article mentions this on the second page at the bottom: http://www.linuxatemyram.com/play.html

Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?

#26
This paragraph: 'But what do you call memory that is both used for something and available for applications? You would call that "free", but Linux calls it "used".' is IMO the best way I've ever seen of explaining the issue. It also reveals the solution: call it free! It is free, after all. Nobody cares about how much free ram is cache unless they are doing something really specific, in which case they should be passing specific flags, or using a specific tool, to report it.

Unfortunately there is no chance Linux will do this, as the relevant reporting tools are too entrenched (and with good reason).

Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?

#28
post #24

Earlier quoted context omitted.

OSX's activity monitor does something similar, it has 4 statuses: Wired, Active, Inactive and Free. Wired and Active are basically the RAM being used (Wired is a special activity status for stuff which can not be moved to disk), Inactive is the cache (generally programs which were used recently) and Free is… well, free. When checking used/free, Inactive and Free count towards free, Wired and Active towards used (thou…

He probably has 8GB of RAM (8192MB); some may be lost to address space holes. I have 12GB, if you're finding that implausible.

> He probably has 8GB of RAM (8192MB)

Yes, I'd expect that, but at the time of my comment (before his stealth edit) all his units read "GB" not "MB". I wrote "8 TB" for a reason.

> I have 12GB, if you're finding that implausible.

I have 8GB RAM in my laptop, why would I find 12GB RAM implausible?

Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?

#29
post #15
post #2

The title of the link (unlike the linked page) suggests that Linux is somehow to blame here... Why? Using RAM for disk caching is a good thing . Besides, this technique is employed by Windows as well. It's just that the average Windows user probably doesn't know how much free RAM his PC has (well, the really average user doesn't know how much total RAM it has). My Windows 7 box takes at least 2GB of memory to itself…

Windows started doing disk caching with Vista and users certainly noticed and complained in much the same way.

Windows started doing pre-emptive caching with Vista, based on the applications you tend to run.

Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?

#30

This is misleading, as the kernel will often swap out processes rather than shrink the disk cache. Its tendency to do this is controlled by the vm.swappiness parameter, which by default heavily favors swapping: http://kerneltrap.org/node/3000 Decreasing this value will favor reducing the cache size and will tend to increase responsiveness. You can set it in the /etc/sysctl.conf file. Low values (≤ 5) are especially g…

I often just turn swap off entirely. A normal workload on my 4GB linux machine will frequently fail to fill even 2GB of buffers. At the moment my machine has still managed to fail to fill 800MB of my RAM with anything and I'm running two virtual machines and doing my usual work load.

I do have a swap partition but only so I can hibernate.

Post reply on HN