From c1055d173e7263ce7618ff4b297daa41b12a765d Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 12 Apr 2011 14:40:51 +1000 Subject: [PATCH] Clamp largest 32bit usable chunk to 2/3 of 1GB. --- main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 8b4fd8e..b76716b 100644 --- a/main.c +++ b/main.c @@ -776,10 +776,13 @@ int main(int argc, char *argv[]) /* Decrease usable ram size on 32 bits due to kernel / * userspace split. Cannot allocate larger than a 1 * gigabyte chunk due to 32 bit signed long being - * used in alloc */ + * used in alloc, and at most 3GB can be malloced, and + * 2/3 of that makes for a total of 2GB to be split + * into thirds. + */ control.usable_ram = MAX(control.ramsize - 900000000ll, 900000000ll); control.maxram = MIN(control.maxram, control.usable_ram); - control.maxram = MIN(control.maxram, one_g); + control.maxram = MIN(control.maxram, one_g * 2 / 3); } else control.usable_ram = control.maxram; round_to_page(&control.maxram);