HuangXingBo commented on a change in pull request #13492: URL: https://github.com/apache/flink/pull/13492#discussion_r495662360
########## File path: flink-python/src/main/java/org/apache/flink/python/PythonOptions.java ########## @@ -156,7 +156,7 @@ */ public static final ConfigOption<Boolean> USE_MANAGED_MEMORY = ConfigOptions .key("python.fn-execution.memory.managed") - .defaultValue(false) + .defaultValue(true) Review comment: We need to also change the default value of `python.fn-execution.memory.managed` in `python_configuration.html` ########## File path: flink-python/pyflink/fn_execution/beam/beam_sdk_worker_main.py ########## @@ -23,10 +25,34 @@ except ImportError: import pyflink.fn_execution.beam.beam_operations_slow +# resource is only available in Unix +try: + import resource + has_resource_module = True +except ImportError: + has_resource_module = False + # force to register the coders to SDK Harness import pyflink.fn_execution.beam.beam_coders # noqa # pylint: disable=unused-import import apache_beam.runners.worker.sdk_worker_main + +def set_memory_limit(): + memory_limit = int(os.environ.get('_PYTHON_WORKER_MEMORY_LIMIT', "-1")) + if memory_limit > 0 and has_resource_module: Review comment: For the case that `has_resource_module is false`, but `memory_limit>0` is set, can we logging a warning. ########## File path: flink-python/src/main/java/org/apache/flink/streaming/api/runners/python/beam/BeamPythonFunctionRunner.java ########## @@ -235,6 +274,14 @@ public void close() throws Exception { jobBundleFactory = null; } + try { + if (sharedResources != null) { + sharedResources.close(); Review comment: ```suggestion sharedResources.close(); ``` ########## File path: flink-python/src/main/java/org/apache/flink/streaming/api/runners/python/beam/BeamPythonFunctionRunner.java ########## @@ -117,13 +120,19 @@ private transient boolean bundleStarted; + private static final String MANAGED_MEMORY_RESOURCE_ID = "python-process-managed-memory"; Review comment: Move the declaration of the variables `MANAGED_MEMORY_RESOURCE_ID` and `PYTHON_WORKER_MEMORY_LIMIT` to the front of `bundleStarted` ? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org