diff options
Diffstat (limited to 'rts')
-rw-r--r-- | rts/posix/OSMem.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/rts/posix/OSMem.c b/rts/posix/OSMem.c index 9ae9a4bd36..479ae9dee1 100644 --- a/rts/posix/OSMem.c +++ b/rts/posix/OSMem.c @@ -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) { |