Fix max heapsize calculation on 32-bit platforms (#6150)

This commit is contained in:
Jakub Kuczys 2023-05-13 01:51:59 +02:00 committed by GitHub
parent 5893d590a7
commit 7f820dab0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,7 +27,7 @@ def get_max_allocation_size(exec) -> Tuple[int, bool]:
max_heap_allowed = psutil.virtual_memory().total max_heap_allowed = psutil.virtual_memory().total
thinks_is_64_bit = True thinks_is_64_bit = True
else: else:
max_heap_allowed = 4 * 1024**3 max_heap_allowed = min(4 * 1024**3, psutil.virtual_memory().total)
thinks_is_64_bit = False thinks_is_64_bit = False
return max_heap_allowed, thinks_is_64_bit 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 min_ram = 64 * 1024**2
# We don't know the java executable at this stage - not worth the extra work required here # 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_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) max_ram = max(min_ram, max_ram_allowed)
size_name = ("", "K", "M", "G", "T") size_name = ("", "K", "M", "G", "T")
i = int(math.floor(math.log(min_ram, 1024))) i = int(math.floor(math.log(min_ram, 1024)))