tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
malloc() exceeds RLIMIT_DATA
Greetings,
Thomas Klausner (wiz@) suggested that I write to this list. It appears that
NetBSD's malloc() will allocate more than RLIMIT_DATA's rlim_max.
The attached use-memory.c will:
1) call getrlimit(RLIMIT_DATA, ...); to find the "soft" and "hard" limits,
as per
http://pubs.opengroup.org/onlinepubs/9699919799/functions/getrlimit.html
2) attempt to allocate twice the "soft" limit.
3) attempt to allocate twice the "hard" limit.
I expected it to fail at #3 and possibly #2, but instead it succeeded all the
time.
I tested it on NetBSD 8.1 inside Virtualbox (2GB memory, 4GB hard drive).
wiz tested it on his NetBSD hardware (32GB RAM, 148GB swap), although I'm not
certain exactly which version of NetBSD he used.
Sample output:
localhost: {4} cc use-memory.c
localhost: {5} ./a.out
soft limit Mb: 256
hard limit Mb: 8192
--
try malloc: 512 MB, 536870912 b
allocated Mb: 512 536870912
x is: 0x7b34c9900000
--
try malloc: 16384 MB, 17179869184 b
allocated Mb: 16384 17179869184
x is: 0x7b30e9900000
localhost: {6}
In case the larger context is helpful, this arose while testing the scrypt
1.2.99 pre-release. Scrypt attempts to use getrlimit(RLIMIT_DATA, ...) to
find out how much memory is available for encryption or decryption.
http://www.tarsnap.com/scrypt.html
Cheers,
- Graham Percival
Home |
Main Index |
Thread Index |
Old Index