English 中文(简体)
Problem allocating heap space over 4 GB when calling java "from Python"
原标题:

I am using using os.system call from python to run jar file. The jar file requires large heap space and thus i am allocating 4 Gb heap space using Xmx. When i execute the command "java -Xms4096m -Xmx4096m -jar camXnet.jar net.txt" from command line it executes properly, however when i call it from a python program via os.system, it works only if memory allocated is less than 4Gb, otherwise it fails to execute. Any solutions?

By fails to execute i mean that A command window appears indicating that os.system has been called and then it disappears, i will check for the error code if any being returned. however no problems are encountered if xmx,xms are set to lower value.

Ok i checked both version and there is a difference The one being called via python is Java HotSpot Client VM mixed mode,sharing while one being called via normal command line is Java HotSpot 64 bit server

How do make os.system in python call the correct one that is the 64 bit server.

UPDATE: I tried using subprocess module as yet the version of java return is same as that from os.system

最佳回答

It s hard to be sure without knowing more detail - like which OS you re on - but my guess is that you re using a 32-bit version of Python which means that when you launch Java, you re also getting the 32-bit version which has a heap size limit of 4GB.

To test if this is the case, compare the output of java -version when run from the command line and when run from your Python script.

问题回答

I was having the same problem launching 64bit Java from 32bit python. I solved the problem using Dave Webb s suggestiong of putting the full path to 64bit Java.exe in the python script. This worked fine so it is not necessary to use 64 bit Python

Just a suggestion, but try using subprocess.call() instead of os.system(), it is preferred and may handle the issue you are experiencing. I m curious to know if it does...





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签