From 4b8ab0859bc47840f5b30bec2bef504cb6ee0980 Mon Sep 17 00:00:00 2001 From: Philipp Hanslovsky Date: Mon, 23 Mar 2020 13:42:35 -0400 Subject: [PATCH] Remove gc_option parameter and rename to set_xmx_if_not_set Otherwise it is impossible to change the garbage collector to, e.g., g1gc --- jgo/__init__.py | 2 +- jgo/util.py | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/jgo/__init__.py b/jgo/__init__.py index 0076299..2c825f8 100644 --- a/jgo/__init__.py +++ b/jgo/__init__.py @@ -1,2 +1,2 @@ from .jgo import resolve_dependencies, _jgo_main as main -from .util import main_from_endpoint, maven_scijava_repository, add_jvm_args_as_necessary +from .util import main_from_endpoint, maven_scijava_repository, set_xmx_if_not_set diff --git a/jgo/util.py b/jgo/util.py index 7b66f2a..d80a48c 100644 --- a/jgo/util.py +++ b/jgo/util.py @@ -3,18 +3,16 @@ from .jgo import _jgo_main as main -def add_jvm_args_as_necessary(argv, gc_option='-XX:+UseConcMarkSweepGC'): + +def set_xmx_if_not_set(argv): """ - Extend existing ``argv`` with reasonable default values for garbage collection and max heap size. + Extend existing ``argv`` with reasonable default values for max heap size. If ``-Xmx`` is not specified in ``argv``, set max heap size to half the system's memory. :param argv: arugment vector - :param gc_option: Use this garbage collector settings, if any. :return: ``argv`` with """ - if gc_option and not gc_option in argv: - argv += [gc_option] for arg in argv: if '-Xmx' in arg: @@ -39,7 +37,8 @@ def main_from_endpoint( repositories={'scijava.public': maven_scijava_repository()}, primary_endpoint_version=None, primary_endpoint_main_class=None, - secondary_endpoints=()): + secondary_endpoints=(), + set_reasonable_default_xmx_if_not_set=True): """ Convenience method to populate appropriate argv for jgo. This is useful to distribute Java programs as Python modules. @@ -66,6 +65,6 @@ def main_from_endpoint( primary_endpoint = primary_endpoint + ':{}'.format(primary_endpoint_main_class) if primary_endpoint_main_class else primary_endpoint endpoint = ['+'.join((primary_endpoint,) + secondary_endpoints)] paintera_argv = argv if double_dash_index < 0 else argv[double_dash_index+1:] - argv = add_jvm_args_as_necessary(jgo_and_jvm_argv) + repository_strings + endpoint + paintera_argv + argv = (set_xmx_if_not_set(jgo_and_jvm_argv) if set_reasonable_default_xmx_if_not_set else jgo_and_jvm_argv) + repository_strings + endpoint + paintera_argv main(argv=argv)