D
Deleted member 67440
Guest
I'm trying to make a fairly realistic estimate of how much RAM is "really" available to a program at any given time (clearly it will vary, it's just an estimate)
By "really free" I mean the amount that can be allocated by a single program, albeit divided into multiple threads, before causing a serious system slowdown, swapping and possibly even trashing
It is, in effect, an archiver that at a certain moment "takes" all the available RAM (minus 25% in order not to slow down excessively) for a certain job.
On Windows the estimate I have made, empirically, is quite good
But now I'm porting to BSD
The header
github.com
...and
shows it is not so easy to answer
A very-quick-and-dirty total RAM size
I cannot / want to use complex libraries, dmesg parsing or command redirection (sysctl, top and so on)
Short version: a quick way to estimate the "Inact" memory (yes, there is ARC that can be "grabbed" etc. But, as I said, better stay on the safe side)
Something like the available of free -m (on Linux)
Thanks to all responders
By "really free" I mean the amount that can be allocated by a single program, albeit divided into multiple threads, before causing a serious system slowdown, swapping and possibly even trashing
It is, in effect, an archiver that at a certain moment "takes" all the available RAM (minus 25% in order not to slow down excessively) for a certain job.
On Windows the estimate I have made, empirically, is quite good
But now I'm porting to BSD
The header
freebsd/sysctl.h at master · lattera/freebsd
FreeBSD's source with custom patches. Contribute to lattera/freebsd development by creating an account on GitHub.
hw.physmem/hw.realmem question
lists.freebsd.org
A very-quick-and-dirty total RAM size
Code:
#if defined(_SC_PHYS_PAGES)
#if defined(_SC_PAGE_SIZE)
long pages=sysconf(_SC_PHYS_PAGES);
long page_size=sysconf(_SC_PAGE_SIZE);
return pages*page_size;
#endif
#endif
I cannot / want to use complex libraries, dmesg parsing or command redirection (sysctl, top and so on)
Code:
root@aserver:/tmp/zp # top |grep -Em2 '^(Mem|Swap):'
Mem: 19M Active, 34G Inact, 188M Laundry, 26G Wired, 739M Buf, 1566M Free
Swap: 16G Total, 217M Used, 16G Free, 1% Inuse
Something like the available of free -m (on Linux)
Thanks to all responders