From 7f820dab0cb3fadbfa70524681ccc3f1ca2cc8bd Mon Sep 17 00:00:00 2001 From: Jakub Kuczys Date: Sat, 13 May 2023 01:51:59 +0200 Subject: [PATCH] Fix max heapsize calculation on 32-bit platforms (#6150) --- redbot/cogs/audio/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/redbot/cogs/audio/utils.py b/redbot/cogs/audio/utils.py index 42a591426..fa123ae6f 100644 --- a/redbot/cogs/audio/utils.py +++ b/redbot/cogs/audio/utils.py @@ -27,7 +27,7 @@ def get_max_allocation_size(exec) -> Tuple[int, bool]: max_heap_allowed = psutil.virtual_memory().total thinks_is_64_bit = True else: - max_heap_allowed = 4 * 1024**3 + max_heap_allowed = min(4 * 1024**3, psutil.virtual_memory().total) thinks_is_64_bit = False return max_heap_allowed, thinks_is_64_bit @@ -36,7 +36,7 @@ def get_jar_ram_defaults() -> Tuple[str, str]: min_ram = 64 * 1024**2 # We don't know the java executable at this stage - not worth the extra work required here max_allocation, is_64bit = get_max_allocation_size(sys.executable) - max_ram_allowed = max_allocation * 0.5 if is_64bit else max_allocation + max_ram_allowed = min(max_allocation, psutil.virtual_memory().total * 0.5) max_ram = max(min_ram, max_ram_allowed) size_name = ("", "K", "M", "G", "T") i = int(math.floor(math.log(min_ram, 1024)))