* [gentoo-user] Free memory issue
@ 2009-08-16 18:41 Raul Gonzales
2009-08-16 18:53 ` [gentoo-user] " Nikos Chantziaras
2009-08-16 18:56 ` [gentoo-user] " Philip Webb
0 siblings, 2 replies; 5+ messages in thread
From: Raul Gonzales @ 2009-08-16 18:41 UTC (permalink / raw
To: gentoo-user; +Cc: rg0076
Hi all,
I wonder what is going on with my system. I have a 2G of physical RAM
but even without any major activity output of free,vmstat and top
reports only ~64M free. Would any one know how to find more - ps doesn't
show nothing wrong...
free -m
total used free shared buffers cached
Mem: 1953 1888 65 0 143 1557
-/+ buffers/cache: 187 1765
Swap: 2055 0 2055
procs -----------memory---------- ---swap-- -----io---- -system--
----cpu----
r b swpd free buff cache si so bi bo in cs us sy
id wa
0 0 0 66720 147196 1594400 0 0 3 10 27 75 0 0
100 0
top - 20:34:42 up 1 day, 9:40, 1 user, load average: 0.00, 0.00, 0.00
Tasks: 99 total, 1 running, 98 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si,
0.0%st
Mem: 2000552k total, 1934028k used, 66524k free, 147200k buffers
Swap: 2104504k total, 0k used, 2104504k free, 1594492k cached
thanks a lot,
Raul
^ permalink raw reply [flat|nested] 5+ messages in thread
* [gentoo-user] Re: Free memory issue
2009-08-16 18:41 [gentoo-user] Free memory issue Raul Gonzales
@ 2009-08-16 18:53 ` Nikos Chantziaras
2009-08-16 18:56 ` [gentoo-user] " Philip Webb
1 sibling, 0 replies; 5+ messages in thread
From: Nikos Chantziaras @ 2009-08-16 18:53 UTC (permalink / raw
To: gentoo-user
On 08/16/2009 09:41 PM, Raul Gonzales wrote:
> Hi all,
>
> I wonder what is going on with my system. I have a 2G of physical RAM
> but even without any major activity output of free,vmstat and top
> reports only ~64M free. Would any one know how to find more - ps doesn't
> show nothing wrong...
>
>
>
>
> free -m
> total used free shared buffers cached
> Mem: 1953 1888 65 0 143 1557
> -/+ buffers/cache: 187 1765
> Swap: 2055 0 2055
Er, I see 1765MB free here (187 used). It's the "-/+ buffers/cache"
line that reports free memory, NOT the first line.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [gentoo-user] Free memory issue
2009-08-16 18:41 [gentoo-user] Free memory issue Raul Gonzales
2009-08-16 18:53 ` [gentoo-user] " Nikos Chantziaras
@ 2009-08-16 18:56 ` Philip Webb
2009-08-16 19:13 ` Andrey Falko
2009-08-16 19:27 ` Alan McKinnon
1 sibling, 2 replies; 5+ messages in thread
From: Philip Webb @ 2009-08-16 18:56 UTC (permalink / raw
To: gentoo-user
090816 Raul Gonzales wrote:
> I have a 2G of physical RAM but even without any major activity
> output of free,vmstat and top reports only ~64M free.
>
> free -m
> total used free shared buffers cached
> Mem: 1953 1888 65 0 143 1557
> -/+ buffers/cache: 187 1765
> Swap: 2055 0 2055
The crucial figure is '187', which is what is usable.
You have a lot of something cached: any idea what it might be ?
-- the kernel should delete that stuff, if it needs the space.
--
========================,,============================================
SUPPORT ___________//___, Philip Webb
ELECTRIC /] [] [] [] [] []| Cities Centre, University of Toronto
TRANSIT `-O----------O---' purslowatchassdotutorontodotca
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [gentoo-user] Free memory issue
2009-08-16 18:56 ` [gentoo-user] " Philip Webb
@ 2009-08-16 19:13 ` Andrey Falko
2009-08-16 19:27 ` Alan McKinnon
1 sibling, 0 replies; 5+ messages in thread
From: Andrey Falko @ 2009-08-16 19:13 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1112 bytes --]
On Sun, Aug 16, 2009 at 11:56 AM, Philip Webb <purslow@ca.inter.net> wrote:
> 090816 Raul Gonzales wrote:
> > I have a 2G of physical RAM but even without any major activity
> > output of free,vmstat and top reports only ~64M free.
> >
> > free -m
> > total used free shared buffers cached
> > Mem: 1953 1888 65 0 143 1557
> > -/+ buffers/cache: 187 1765
> > Swap: 2055 0 2055
>
> The crucial figure is '187', which is what is usable.
> You have a lot of something cached: any idea what it might be ?
> -- the kernel should delete that stuff, if it needs the space.
>
> All Disk I/O is cached into memory. A good example is if you are playing a
video game. Every time you load a new map, that map is cached in memory, so
if you load that map again, the kernel won't get it from disk, but from the
memory's cache. If your OS needs more ram, the cache is over-written with
actual memory. Here is a simple explaination of what I'm talking about:
http://linux.about.com/od/lsa_guide/a/gdelsa44.htm
[-- Attachment #2: Type: text/html, Size: 1659 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [gentoo-user] Free memory issue
2009-08-16 18:56 ` [gentoo-user] " Philip Webb
2009-08-16 19:13 ` Andrey Falko
@ 2009-08-16 19:27 ` Alan McKinnon
1 sibling, 0 replies; 5+ messages in thread
From: Alan McKinnon @ 2009-08-16 19:27 UTC (permalink / raw
To: gentoo-user
On Sunday 16 August 2009 20:56:59 Philip Webb wrote:
> 090816 Raul Gonzales wrote:
> > I have a 2G of physical RAM but even without any major activity
> > output of free,vmstat and top reports only ~64M free.
> >
> > free -m
> > total used free shared buffers cached
> > Mem: 1953 1888 65 0 143 1557
> > -/+ buffers/cache: 187 1765
> > Swap: 2055 0 2055
>
> The crucial figure is '187', which is what is usable.
> You have a lot of something cached: any idea what it might be ?
> -- the kernel should delete that stuff, if it needs the space.
top, free and every other tool that examines /proc lies through it's teeth.
Well, not really, but it's necessary to know what exactly it is measuring and
also how the kernel is written.
But first: Raul, there is nothing wrong with your box. It is working as
designed.
The "used" column literally means memory that in use for something, somewhere.
The "free" column literally means memory that is not in use anywhere. It's
normally around 2 or 3 % of total physical RAM.
In Raul's case, the kernel has decided to allocate 1557M of RAM to cache. A
particular block might have cached data in it, or it might not. It might have
been used then marked as up for not in use anymore, or it might never have
been written to since last reboot. It doesn't matter. All that does matter is
that the kernel has decided that those blocks of memory *may* be used for
caching.
The trick is that if more memory is needed by apps than what is listed as
immediately available and free, the kernel will search out chunks that it can
de-allocate, then it will do so.
Why does the kernel do this? It's a programming technique called lazy-
deallocation (similar to lazy-initialization) and it's used because it is
efficient. It means the kernel only has to do work when it needs to do work.
De-allocating memory as soon as it is not in use is expensive and usually a
waste of time - it's very likely that that very chunk of memory will almost
immediately be used once again. If so, why bother de-allocating it at all?
Bottom line: You, the user, do not really know what the kernel is doing with
memory. It's also changing about 100 million times a second and your eyes
don't work that fast. The kernel is designed to do these things in an
autonomous fashion because it knows what to do, and you the user do not. The
most you can do about this is provide hints as to how the kernel should
operate and then let it get on with it.
top, free, et all, simply show snapshots of memory state at a point in time.
You should ignore the absolute values they display and concentrate more on how
the numbers are changing over time. A value that gradually increases while no
real processes are running would indicate a problem for example.
This is all very correct and follows good engineering principles.
--
alan dot mckinnon at gmail dot com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-08-16 19:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-16 18:41 [gentoo-user] Free memory issue Raul Gonzales
2009-08-16 18:53 ` [gentoo-user] " Nikos Chantziaras
2009-08-16 18:56 ` [gentoo-user] " Philip Webb
2009-08-16 19:13 ` Andrey Falko
2009-08-16 19:27 ` Alan McKinnon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox