Issue2532

classification
Title: JVM memory settings are ignored on GNU/Linux by cpython launch script
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.7
Milestone:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: jamesmudd, stefan.richthofer, stuckyb
Priority: Keywords:

Created on 2016-11-14.20:33:26 by stuckyb, last changed 2017-03-21.20:44:42 by jamesmudd.

Messages
msg10987 (view) Author: stuckyb (stuckyb) Date: 2016-11-14.20:42:37
When running jython on Xubuntu 15.10, JVM heap size arguments are ignored.  E.g., I passed -Xmx512m to the JVM in two ways: via the jython launch script as -J-Xmx512m, and by setting the value of the JAVA_MEM environment variable.  In both cases, running jython with the --print option confirmed that the JVM argument was correctly parsed and passed to the call of the JVM.  However, when executing a memory-intensive script, the Java process always used approximate 2.1 GB of RAM regardless of whether I set -Xmx much lower or much higher than 2 GB.

The problem seems to be with the call to os.execvp() in the jython launch script (line 431).  If I have jython print the java command string, then execute this command directly on the command line, the JVM memory limits behave exactly as expected.
msg11040 (view) Author: Stefan Richthofer (stefan.richthofer) Date: 2017-01-28.15:14:59
stuckyb,
good you found a workaround. You could alternatively try the CPython-launch script for Jython (bin/jython.py); would be nice to know if the issue occurs there as well.
Finally, for Linux you can try LiJy-Launch, a JNI-based Jython launcher (https://github.com/Stewori/LiJy-launch), working by a similar approach like the original Java-launcher.

Do you have an example code-snippet available that demonstrates the memory limit?
msg11260 (view) Author: James Mudd (jamesmudd) Date: 2017-03-21.20:44:41
I can reproduce this and it is actually an issue with the cpython launch script when used on Linux (it's ok on Windows). The shell script works correctly and should probably be used on Linux, but this should still be fixed I guess.

With shell script:
james@james-ubuntu:~/git/jython/dist$ ./bin/jython -J-Xmx345m
Jython 2.7.1rc1 (, Mar 21 2017, 20:17:11) 
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_111
Type "help", "copyright", "credits" or "license" for more information.
>>> from java.lang.management import ManagementFactory
>>> ManagementFactory.getRuntimeMXBean().getInputArguments()
[-Xmx345m, -Xss2560k, -Dpython.home=., -Dpython.executable=./bin/jython]

But with cpython launch script:
james@james-ubuntu:~/git/jython/dist$ python bin/jython.py -J-Xmx345m
Jython 2.7.1rc1 (, Mar 21 2017, 20:17:11) 
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_111
Type "help", "copyright", "credits" or "license" for more information.
>>> from java.lang.management import ManagementFactory
>>> ManagementFactory.getRuntimeMXBean().getInputArguments()
[-Xss2560k, -Dpython.home=/home/james/git/jython/dist, -Dpython.executable=/home/james/git/jython/dist/bin/jython.py, -Dpython.launcher.uname=linux, -Dpython.launcher.tty=true]
>>>
The Xmx setting doesn't get passed to the JVM

If you add the --print it correctly shows the -Xmx arg which should be passed.

It does seem to be caused by the use of os.execvp on line 431 instead of using subprocess.call which will be used on Windows, i'm assuming there is some good reason for this difference?
History
Date User Action Args
2017-03-21 20:44:42jamesmuddsetnosy: + jamesmudd
messages: + msg11260
title: JVM memory settings are ignored on GNU/Linux -> JVM memory settings are ignored on GNU/Linux by cpython launch script
2017-01-28 15:15:00stefan.richthofersetnosy: + stefan.richthofer
messages: + msg11040
2016-11-14 20:42:37stuckybsetmessages: + msg10987
2016-11-14 20:33:26stuckybcreate