In a multitasking OS, even if at some instance you know how much memory
is free, by the time some decision is made based on the knowledge, the
figure is out of date because some other process could have run and
allocated megabytes of space for itself.
The best strategy is simply to try to get the memory and recover from
failure.
If your program can tune itself based on the availability of memory
(e.g. choose from a range of algorithms with different time/space
tradeoffs) this is probably best left as a configuration option.
> thanks,
Iwo
> > thanks,
> You can read /proc/meminfo but don't trust the values too much.
> See previous post for reason. :^)
> Iwo
Also look what the shell command free does,
it actually reports free+buffers+cache which
on the other hand might be to much.
The memory reported as buffers and cache in
/proc/meminfo will in many cases be freed
if a program request it, but not always.
Even if there is not enough physical memory
the program may still run using swapspace.
And NEVER write a program that refuses to
run because it THINKS there is not enough
memory. If the user wants to run the program
allow him to do so, don't report errors
before you have to do because malloc returns
NULL.
--
Kasper Dupont
1. How to check the amount of free memory in share memory
Hi,
I know that ipcs can check the owner of the program using the shared
memory. How to check whether the amount of available share memory in
the system?
2. Newbie'questions about shell
3. How to know the amount of real memory and number of cpu
5. Does anyone know how to get hardware configuration such as processor speed and memory amount?
6. Ali M1489 EIDE chipset. Linux driver?
7. how to determine amount of free memory
8. swap mouse buttons for lefty?
9. How to obtain information on amount of Free/Total system/user memory
10. Getting the total amount of free memory available under Unix Solaris 2.5
11. real amount of free memory
12. How to get the free memory amount ?
13. actual free amount of memory left on system