tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: malloc() exceeds RLIMIT_DATA



On Thu, Jul 11, 2019 at 05:26:34PM +0000, David Holland wrote:
> In practice (across arbitrary platforms) I wouldn't count on malloc
> necessarily respecting any of these limits,

Indeed, which was probably a large reason why this code is trying to find out
how much memory it should use.  In our attempt to be cross-platform, we check
(with the appropriate #ifdefs):
- sysctl's HW_USERMEM and HW_MEMSIZE
- sysinfo
- getrlimit's RLIMIT_AS, RLIMIT_RSS, (and perhaps RLIMIT_DATA if neither of
  the other two are defined; awaiting code review)
- sysconf's _SC_PAGE_SIZE and _SC_PHYS_PAGES

and pick the lowest out of all of them.

Cheers,
- Graham


Home | Main Index | Thread Index | Old Index