diff --git a/mx.graalpython/mx_graalpython.py b/mx.graalpython/mx_graalpython.py index f2e85d7998..af47f26391 100644 --- a/mx.graalpython/mx_graalpython.py +++ b/mx.graalpython/mx_graalpython.py @@ -527,6 +527,19 @@ def libpythonvm_build_args(): # MAP_JIT memory is mapped next to the (ASLR-slid) dylibs. build_args += ['-H:-RandomizeRuntimeCodeCache'] + if not graalos and not _is_overridden_native_image_arg("-R:MaxNewSize"): + # The serial collector starts with a 128 MB heap and a young generation of about 48 MB, and is + # allowed to grow the young generation to 10% of physical memory. Every page of the young + # generation is touched before the first collection and stays resident, so a small program + # keeps tens of MB of garbage. A 16 MB young generation bounds that; --vm.Xmn overrides it. + build_args += ['-R:MaxNewSize=16777216'] + + if not graalos and not _is_overridden_native_image_arg("-R:+CompileInIsolates") and not _is_overridden_native_image_arg("-R:-CompileInIsolates"): + # Runtime compilation runs in a separate isolate by default, with its own heap (which starts + # with a young generation of about 48 MB) and a second mapping of the image heap that it + # touches. Compile in the main isolate instead; --vm.XX:+CompileInIsolates restores it. + build_args += ['-R:-CompileInIsolates'] + profile = None require_profile = get_boolean_env("GRAALPY_REQUIRE_PGO_PROFILE") if (