I'm running some Java code through Python's pyjnius package, version 1.2.0. There are several Python processes that each call the same Java class with different inputs, so each one initializes its own JVM. The problem I'm having is a memory issue, but in researching that, I found that the options in the running JVMs aren't the same as what I'm setting in my Python code.
I'm setting the options with:
jnius_config.add_options('-Xms512m', '-Xmx1280m')
After the Java code is running I run jps from a command line and I get the following output:
C:\>jps -lvm
25140 -Xmx1280m -Xmx1280m
24684 -Xmx1280m -Xmx1280m
I tried different arguments to add_options
, and jps always reports two copies of the second argument for each of the JVMs. I also tried using set_options
and got the same results.
I checked that the options are set in the pyjnius module itself using jnius_config.get_options()
before and after adding options.
print("Initial options:", jnius_config.get_options())
jnius_config.add_options('-Xms512m', '-Xmx1280m')
print("Configured options:", jnius_config.get_options())
It reports the same values that I set.
Initial options: []
Configured options: ['-Xms512m', '-Xmx1280m']
But the JVMs still seem to be running with the wrong options set when I check them in jps. Other running JVMs report different options, so I don't think this is a problem in jps, since only the processes run through pyjnius are giving me back the wrong values.
Does anyone know if this is a bug in pyjnius? Is there another way to check the options a JVM was launched with?
I wasn't sure if I should trust the values reported by jps or pyjnius, but I see the following lines in an error log created when running my Python script:
VM Arguments:
jvm_args: -Xmx1280m -Xmx1280m
java_command: <unknown>
It looks pretty conclusive that pyjnius is setting the wrong options.
I experimented a bit with the initial memory size option and found that this problem only exists when the initial memory size is -Xms100m
or greater. When I set the initial value to -Xms99m
or lower, jps reports the same values that I set.