Skip to content
Snippets Groups Projects
Commit 26273774 authored by Ben Gamari's avatar Ben Gamari Committed by Ben Gamari
Browse files

rts: Query system rlimit for maximum address-space size

When we attempt to reserve the heap, we query the system's rlimit to
establish the starting point for our search over sizes.

Test Plan: Validate

Reviewers: erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14492

Differential Revision: https://phabricator.haskell.org/D4754
parent 21e9d4f5
No related branches found
No related tags found
No related merge requests found
......@@ -36,6 +36,10 @@
#if defined(HAVE_NUMAIF_H)
#include <numaif.h>
#endif
#if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_SYS_TIME_H)
#include <sys/time.h>
#include <sys/resource.h>
#endif
#include <errno.h>
......@@ -502,6 +506,13 @@ void *osReserveHeapMemory(void *startAddressPtr, W_ *len)
(void*)startAddress, (void*)minimumAddress);
}
#if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_SYS_TIME_H)
struct rlimit limit;
if (!getrlimit(RLIMIT_AS, &limit) && *len > limit.rlim_cur) {
*len = limit.rlim_cur;
}
#endif
attempt = 0;
while (1) {
if (*len < MBLOCK_SIZE) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment