Message5363

Author rkurin
Recipients rkurin
Date 2009-12-08.21:03:07
SpamBayes Score 0.0
Marked as misclassified No
Message-id <1260306189.54.0.532066560048.issue1522@psf.upfronthosting.co.za>
In-reply-to
Content
Executing the python script repeatedly that imports another python class
causing OOM: PermGen exception.

After investigating this further the class org.python.core.PyType has a
static "class_to_type" map that never gets cleaned up and holds
references to generated class files and that does not allow those
classes to be clean up from PermGen. 

class_to_type has thousands of references to PythonPOSIXHandler$<some
number>. I believe the problem happens when python script imports a
class defined in python. 

The code that causes the OOM after about 30 min with -XX:MaxPermSize=32m
is included. 

Java class with the main method to run: 

public class JythonProblemTest {
	public static void main(String[] args) throws Exception
	{
		while(true)
		{
			PythonInterpreter inter = null;
			try
			{
				inter = new PythonInterpreter(null, new PySystemState());
				inter.execfile("python_src/test.py");
			}
			finally
			{
				if (inter!= null) 
				{
					inter.cleanup();
				}
			}
		}
	}
}

---------------------------------------------------------------

Python script to be executed by Java main method: 

from os import path

class MyClass(Exception):
    '''
    classdocs
    '''
    def __init__(self):
        pass

if __name__ == '__main__' or __name__ == 'main':
    pass
History
Date User Action Args
2009-12-08 21:03:09rkurinsetrecipients: + rkurin
2009-12-08 21:03:09rkurinsetmessageid: <1260306189.54.0.532066560048.issue1522@psf.upfronthosting.co.za>
2009-12-08 21:03:09rkurinlinkissue1522 messages
2009-12-08 21:03:08rkurincreate