I have a user who is having a java heap problem when running a scripted button that downloads a gz file off an FTP site and then unzips the file.
we have been using the screen for several years now, but the downloaded file has grown. the file is currently 124 MB and is a csv file that contains ~668,000 lines.
i have the client set to an initial memory of 512MB and a max memory of 1024MB. if i try changing the max to 2048 the client will not launch.
is there something i can do so the client does not run out of memory unzipping the file?
here is the snippet of code
import java
import org.python.core
import gzip
import java.lang.StringBuffer as SB
gzipFile = gzip.open(filename) #open read-binary file f with name fn
contents = gzipFile.read() #THIS IS LINE 51
gzipFile.close()
print "file unzipped"
Traceback (most recent call last):
File "event:actionPerformed ", line 51, in runThread
File "C:\Users\rhonda.SIERRANEVADA\AppData\LocalLow\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\gzip.py", line 224, in read
self._read(readsize)
File "C:\Users\rhonda.SIERRANEVADA\AppData\LocalLow\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\gzip.py", line 224, in read
self._read(readsize)
File "C:\Users\rhonda.SIERRANEVADA\AppData\LocalLow\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\gzip.py", line 284, in _read
self._add_read_data( uncompress )
File "C:\Users\rhonda.SIERRANEVADA\AppData\LocalLow\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\gzip.py", line 301, in _add_read_data
self.extrabuf = self.extrabuf + data
java.lang.OutOfMemoryError: Java heap space
at java.lang.String.concat(Unknown Source)
at org.python.core.PyString.str___add__(PyString.java:741)
at org.python.core.PyString.__add__(PyString.java:731)
at org.python.core.PyObject._basic_add(PyObject.java:2009)
at org.python.core.PyObject._add(PyObject.java:1995)
at gzip$py._add_read_data$18(C:\Users\rhonda.SIERRANEVADA\AppData\LocalLow\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\gzip.py:303)
at gzip$py.call_function(C:\Users\rhonda.SIERRANEVADA\AppData\LocalLow\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\gzip.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:149)
at org.python.core.PyFunction.__call__(PyFunction.java:327)
at org.python.core.PyMethod.__call__(PyMethod.java:124)
at gzip$py._read$17(C:\Users\rhonda.SIERRANEVADA\AppData\LocalLow\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\gzip.py:297)
at gzip$py.call_function(C:\Users\rhonda.SIERRANEVADA\AppData\LocalLow\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\gzip.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:149)
at org.python.core.PyFunction.__call__(PyFunction.java:327)
at org.python.core.PyMethod.__call__(PyMethod.java:124)
at gzip$py.read$15(C:\Users\rhonda.SIERRANEVADA\AppData\LocalLow\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\gzip.py:242)
at gzip$py.call_function(C:\Users\rhonda.SIERRANEVADA\AppData\LocalLow\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\gzip.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:301)
at org.python.core.PyBaseCode.call(PyBaseCode.java:127)
at org.python.core.PyFunction.__call__(PyFunction.java:317)
at org.python.core.PyMethod.__call__(PyMethod.java:109)
at org.python.pycode._pyx36.runThread$1(<event:actionPerformed>:124)
at org.python.pycode._pyx36.call_function(<event:actionPerformed>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:301)
at org.python.core.PyBaseCode.call(PyBaseCode.java:114)
at org.python.core.PyFunction.__call__(PyFunction.java:307)
at org.python.core.PyFunction.__call__(PyFunction.java:302)
at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:551)
java.lang.OutOfMemoryError: java.lang.OutOfMemoryError: Java heap space
at org.python.core.PyException.fillInStackTrace(PyException.java:70)
at java.lang.Throwable.<init>(Throwable.java:181)
at java.lang.Exception.<init>(Unknown Source)
at java.lang.RuntimeException.<init>(Unknown Source)
at org.python.core.PyException.<init>(PyException.java:46)
at org.python.core.PyException.<init>(PyException.java:43)
at org.python.core.Py.JavaError(Py.java:481)
at org.python.core.PyTableCode.call(PyTableCode.java:168)
at org.python.core.PyBaseCode.call(PyBaseCode.java:149)
at org.python.core.PyFunction.__call__(PyFunction.java:327)
at org.python.core.PyMethod.__call__(PyMethod.java:124)
at gzip$py._read$17(C:\Users\rhonda.SIERRANEVADA\AppData\LocalLow\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\gzip.py:297)
at gzip$py.call_function(C:\Users\rhonda.SIERRANEVADA\AppData\LocalLow\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\gzip.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:149)
at org.python.core.PyFunction.__call__(PyFunction.java:327)
at org.python.core.PyMethod.__call__(PyMethod.java:124)
at gzip$py.read$15(C:\Users\rhonda.SIERRANEVADA\AppData\LocalLow\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\gzip.py:242)
at gzip$py.call_function(C:\Users\rhonda.SIERRANEVADA\AppData\LocalLow\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\gzip.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:301)
at org.python.core.PyBaseCode.call(PyBaseCode.java:127)
at org.python.core.PyFunction.__call__(PyFunction.java:317)
at org.python.core.PyMethod.__call__(PyMethod.java:109)
at org.python.pycode._pyx36.runThread$1(<event:actionPerformed>:124)
at org.python.pycode._pyx36.call_function(<event:actionPerformed>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:301)
at org.python.core.PyBaseCode.call(PyBaseCode.java:114)
at org.python.core.PyFunction.__call__(PyFunction.java:307)
at org.python.core.PyFunction.__call__(PyFunction.java:302)
at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:551)
at com.inductiveautomation.factorypmi.application.script.builtin.ClientSystemUtilities$3.run(ClientSystemUtilities.java:306)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: Java heap space
at java.lang.String.concat(Unknown Source)
at org.python.core.PyString.str___add__(PyString.java:741)
at org.python.core.PyString.add (PyString.java:731)
at org.python.core.PyObject._basic_add(PyObject.java:2009)
at org.python.core.PyObject._add(PyObject.java:1995)
at gzip$py._add_read_data$18(C:\Users\rhonda.SIERRANEVADA\AppData\LocalLow\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\gzip.py:303)
at gzip$py.call_function(C:\Users\rhonda.SIERRANEVADA\AppData\LocalLow\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\gzip.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:149)
at org.python.core.PyFunction.call (PyFunction.java:327)
at org.python.core.PyMethod.call (PyMethod.java:124)
at gzip$py._read$17(C:\Users\rhonda.SIERRANEVADA\AppData\LocalLow\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\gzip.py:297)
at gzip$py.call_function(C:\Users\rhonda.SIERRANEVADA\AppData\LocalLow\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\gzip.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:149)
at org.python.core.PyFunction.call (PyFunction.java:327)
at org.python.core.PyMethod.call (PyMethod.java:124)
at gzip$py.read$15(C:\Users\rhonda.SIERRANEVADA\AppData\LocalLow\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\gzip.py:242)
at gzip$py.call_function(C:\Users\rhonda.SIERRANEVADA\AppData\LocalLow\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\gzip.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:301)
at org.python.core.PyBaseCode.call(PyBaseCode.java:127)
at org.python.core.PyFunction.call (PyFunction.java:317)
at org.python.core.PyMethod.call (PyMethod.java:109)
at org.python.pycode._pyx36.runThread$1(event:actionPerformed :124)
at org.python.pycode._pyx36.call_function(event:actionPerformed )
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:301)
at org.python.core.PyBaseCode.call(PyBaseCode.java:114)
at org.python.core.PyFunction.call (PyFunction.java:307)
at org.python.core.PyFunction.call (PyFunction.java:302)
at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:551)
Ignition v7.5.3 (b1163)
Java: Sun Microsystems Inc. 1.6.0_30
If you launch the client using a 64-bit version of Java you should be able to increase the memory to 2048. It won’t launch on a 32-bit Java since it has a max of 1024 MB of memory. Does it work if you use a 64-bit version of Java or do you get the same problem?
it works on my 64-bit version of java.
Well it seems there is a memory issue with Jython when using gzip. You can try putting this code before your script runs to see if it helps:from java.lang import System
System.setProperty("python.options.internalTablesImpl","weak")
Run it on a 32-bit Java and let me know.