tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: malloc() exceeds RLIMIT_DATA
On Tue, Jul 09, 2019 at 07:17:39AM +0200, Martin Husemann wrote:
> The classical "data segment" (limited by RLIMIT_DATA) is not used much
> nowadays in NetBSD. Especially malloc() does not use it.
>
> RLIMIT_DATA The maximum size (in bytes) of the data segment for a
> process; this defines how far a program may extend its
> break with the sbrk(2) system call.
>
>
> In ancient times malloc allocated memory via sbrk(2), but nowadays it uses
> mmap(2) with anonymous memory.
I have no complaint about the internal implementation of malloc(). But POSIX
says that:
RLIMIT_DATA
This is the maximum size of a data segment of the process, in bytes. If
this limit is exceeded, the malloc() function shall fail with errno set to
[ENOMEM].
http://pubs.opengroup.org/onlinepubs/9699919799/functions/getrlimit.html
The relevant part is the second sentence. My interpretation of that sentence
is that if malloc() does *not* fail when it is asked to exceed RLIMIT_DATA,
then it is not following the POSIX standard.
(In other communication, Colin Percival says that FreeBSD uses jemalloc, and
RLIMIT_DATA doesn't affect it, and that "... we should probably fix that some
day". But since FreeBSD's RLIMIT_DATA is set to a much larger value than
NetBSD (256 MB for rlim_cur), nobody noticed.)
Cheers,
- Graham
Home |
Main Index |
Thread Index |
Old Index