detecting memory size?
Joachim Durchholz
joachim.durchholz at web.de
Thu Jan 29 18:37:43 EST 2004
Ketil Malde wrote:
> What I really want is the amount of
> memory my application can allocate and excercise lively without
> causing thrashing. On my Linux computer, that amounts more or less to
> the installed, physical RAM, minus a bit, so I'll settle for that. :-)
An easier way would be to make this a configuration option at
installation time - the justification being that users probably have a
better idea of how much RAM should be allowed to the program.
> Perhaps the best approach would be to use getrusage(), and try to
> decrease memory use if/when there is a lot of page faults happening?
The problem is that you'll have trouble finding out the page fault rate
- that's even less portable than finding out available RAM. On some
Windows versions, this information is available but undocumented, and
changed location and format on several occasions IIRC. You might also
need administrator privileges to access that kind of information...
The best you can do is to check whether your program is slowing down,
and reduce memory usage if it does. That's not a very reliable
measurement practice though... and if your program is getting slower
when it's RAM-starved, you may even end up in a self-starvation spiral...
Regards,
Jo
--
Currently looking for a new job.
More information about the Glasgow-haskell-users
mailing list