Hi Folks,
As we all know, the "free memory" reported by e.g. 'free' is usually very small. E.g. on this machine (endowed with "a massive 128MB RAM" (OK it's an oldish laptop and I'm cynically quoting typical ad material) I get
free
total used free shared buffers cached Mem: 126024 117952 8072 0 1476 50184 -/+ buffers/cache: 66292 59732 Swap: 400640 124092 276548
and of course the "free 8072" is illusory. In reality much more is available -- at least, I suppose, the 59732KB "free" in buffers/cache, though I;m not really sure about this since I don't know the underlying details of this report.
My Question is: suppose I want to embark on a RAM-intensive task, e.g. a numerical computation with large objects, or maybe a CD burn, where I'd like to make the most use of RAM. I can tell the application how much RAM it can expect to use.
So: How can I determine, by some system command, how much of the RAM is actually up for grabs. so that I can tell the program to use (e.g.) 64MB RAM?
In other words, how could I find out that 64MB RAM would be available?
And should I use 'nice' to make sure that the program can jump the queue?
All advice appreciated!
Best wishes to all, Ted.
-------------------------------------------------------------------- E-Mail: (Ted Harding) Ted.Harding@nessie.mcc.ac.uk Fax-to-email: +44 (0)870 167 1972 Date: 27-Jul-04 Time: 19:18:28 ------------------------------ XFMail ------------------------------
Thus may double-count shared libraries, but you could try
ps aux|grep -v MEM|awk '{total += $4 }; END { print total}'
which will add up the total %age memory used by each process.
To see if you really have a memory problem (i.e. has the system really run out of memory) you need to look at swapping rather than memory usage : vmstat 2 will show you : look for non-zero numbers on si and so.
Iain.
On Tuesday 27 July 2004 19:18, Ted Harding wrote:
Hi Folks,
As we all know, the "free memory" reported by e.g. 'free' is usually very small. E.g. on this machine (endowed with "a massive 128MB RAM" (OK it's an oldish laptop and I'm cynically quoting typical ad material) I get
free
total used free shared buffers cached
Mem: 126024 117952 8072 0 1476 50184 -/+ buffers/cache: 66292 59732 Swap: 400640 124092 276548
and of course the "free 8072" is illusory. In reality much more is available -- at least, I suppose, the 59732KB "free" in buffers/cache, though I;m not really sure about this since I don't know the underlying details of this report.
My Question is: suppose I want to embark on a RAM-intensive task, e.g. a numerical computation with large objects, or maybe a CD burn, where I'd like to make the most use of RAM. I can tell the application how much RAM it can expect to use.
So: How can I determine, by some system command, how much of the RAM is actually up for grabs. so that I can tell the program to use (e.g.) 64MB RAM?
In other words, how could I find out that 64MB RAM would be available?
And should I use 'nice' to make sure that the program can jump the queue?
All advice appreciated!
Best wishes to all, Ted.
E-Mail: (Ted Harding) Ted.Harding@nessie.mcc.ac.uk Fax-to-email: +44 (0)870 167 1972 Date: 27-Jul-04 Time: 19:18:28 ------------------------------ XFMail ------------------------------
On 27-Jul-04 Iain Roberts wrote:
Thus may double-count shared libraries, but you could try
ps aux|grep -v MEM|awk '{total += $4 }; END { print total}'
which will add up the total %age memory used by each process.
... which very nicely gives:
$ free total used free shared buffers cached Mem: 126024 120792 5232 0 1580 52824 -/+ buffers/cache: 66388 59636 Swap: 400640 133808 266832
$ ps aux|grep -v MEM|awk '{total += $4 }; END { print total}' 59.4
which presumably suggests I should have about 60MB to play with.
Glad to encounter another 'awk' fan! Thanks for the tip about $4 in 'ps': I'd been expecting to find it somewhere there if I only knew just how to look.
To see if you really have a memory problem (i.e. has the system really run out of memory) you need to look at swapping rather than memory usage : vmstat 2 will show you : look for non-zero numbers on si and so.
And thanks for this tip too. Best wishes, Ted.
-------------------------------------------------------------------- E-Mail: (Ted Harding) Ted.Harding@nessie.mcc.ac.uk Fax-to-email: +44 (0)870 167 1972 Date: 28-Jul-04 Time: 08:11:12 ------------------------------ XFMail ------------------------------
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Wednesday 28 July 2004 08:11, Ted Harding wrote:
... which very nicely gives:
$ cat /proc/meminfo MemTotal: 516436 kB MemFree: 42784 kB Buffers: 20248 kB Cached: 77360 kB SwapCached: 104652 kB Active: 277764 kB Inactive: 42760 kB HighTotal: 0 kB HighFree: 0 kB LowTotal: 516436 kB LowFree: 42784 kB SwapTotal: 1028152 kB SwapFree: 719308 kB Dirty: 576 kB Writeback: 0 kB Mapped: 253976 kB Slab: 145460 kB Committed_AS: 682280 kB PageTables: 4044 kB VmallocTotal: 516056 kB VmallocUsed: 6580 kB VmallocChunk: 509472 kB
Kind Regards,
Ian - -- Ian P. Christian - pookey@pookey.co.uk - http://www.pookey.co.uk/
What is /proc/meminfo telling me about real free memory?
On my system, none of the figures look similar to the total of used memory from ps aux; the "Cached" figure is close to what ps aux tells me is the amount of memory not being used by processes. Is this right, or just coincidence? (Or is ps aux a totally inaccurate guide and one of the figures below is the real free memory number?)
Iain.
On Wednesday 28 July 2004 08:47, Ian P. Christian wrote:
On Wednesday 28 July 2004 08:11, Ted Harding wrote:
... which very nicely gives:
$ cat /proc/meminfo MemTotal: 516436 kB MemFree: 42784 kB Buffers: 20248 kB Cached: 77360 kB SwapCached: 104652 kB Active: 277764 kB Inactive: 42760 kB HighTotal: 0 kB HighFree: 0 kB LowTotal: 516436 kB LowFree: 42784 kB SwapTotal: 1028152 kB SwapFree: 719308 kB Dirty: 576 kB Writeback: 0 kB Mapped: 253976 kB Slab: 145460 kB Committed_AS: 682280 kB PageTables: 4044 kB VmallocTotal: 516056 kB VmallocUsed: 6580 kB VmallocChunk: 509472 kB
Kind Regards,
Ian
On Tue, 27 Jul 2004 Ted.Harding@nessie.mcc.ac.uk wrote:
Hi Folks,
As we all know, the "free memory" reported by e.g. 'free' is usually very small. E.g. on this machine (endowed with "a massive 128MB RAM" (OK it's an oldish laptop and I'm cynically quoting typical ad material) I get
free
total used free shared buffers cached
Mem: 126024 117952 8072 0 1476 50184 -/+ buffers/cache: 66292 59732 Swap: 400640 124092 276548
and of course the "free 8072" is illusory. In reality much more is available -- at least, I suppose, the 59732KB "free" in buffers/cache, though I;m not really sure about this since I don't know the underlying details of this report.
Linux uses spare memory for disk buffering/caching. so the top "free" figure will always be small on any well used machine. It doesn't need this disk buffering, it can use none or all your memory - the figure below is the amount of memory available for use by an application - if all were used then there would be no extensive disk buffering/caching.
My Question is: suppose I want to embark on a RAM-intensive task, e.g. a numerical computation with large objects, or maybe a CD burn, where I'd like to make the most use of RAM. I can tell the application how much RAM it can expect to use.
So: How can I determine, by some system command, how much of the RAM is actually up for grabs. so that I can tell the program to use (e.g.) 64MB RAM?
In other words, how could I find out that 64MB RAM would be available?
And should I use 'nice' to make sure that the program can jump the queue?
All advice appreciated!
Best wishes to all, Ted.
E-Mail: (Ted Harding) Ted.Harding@nessie.mcc.ac.uk Fax-to-email: +44 (0)870 167 1972 Date: 27-Jul-04 Time: 19:18:28 ------------------------------ XFMail ------------------------------