From: Samuele P. <pe...@in...> - 2001-09-22 03:15:40
|
Hi. > Can anyone explain why the attached simple Java program which creates one > PythonInterpreter and then does an eval in a continuous loop using so much > memory on Windows 2000 and Linux? Is it a Java problem or a Jython > problem? Can it be fixed? Given your data it seems an IBM Java problem ;) Seriously the only potential memory leak that I see is with the all classes dynamically loaded if the VM does not discard them at some point, which is not mandatory (see the JLS) but should be a reasonable behavior ;) With the Sun HotSpot you have a -verbose:class option. Don't know about the IBM VM. Here is what you see running your code: a bunch of dynamical class loading: [Loaded org.python.pycode._pyx4667] [Loaded org.python.pycode._pyx4668] [Loaded org.python.pycode._pyx4669] [Loaded org.python.pycode._pyx4670] [Loaded org.python.pycode._pyx4671] [Loaded org.python.pycode._pyx4672] [Loaded org.python.pycode._pyx4673] [Loaded org.python.pycode._pyx4674] [Loaded org.python.pycode._pyx4675] [Loaded org.python.pycode._pyx4676] [Loaded org.python.pycode._pyx4677] [Loaded org.python.pycode._pyx4678] [Loaded org.python.pycode._pyx4679] ... [Unloading class org.python.pycode._pyx6636] [Unloading class org.python.pycode._pyx6538] [Unloading class org.python.pycode._pyx6593] [Unloading class org.python.pycode._pyx6598] [Unloading class org.python.pycode._pyx7066] [Unloading class org.python.pycode._pyx7002] [Unloading class org.python.pycode._pyx6510] [Unloading class org.python.pycode._pyx6785] [Unloading class org.python.pycode._pyx6621] [Unloading class org.python.pycode._pyx6892] [Unloading class org.python.pycode._pyx6863] [Unloading class org.python.pycode._pyx6707] [Unloading class org.python.pycode._pyx6633] but also a bunch of class unloading. If the IBM VM have similar tools, you could try to investigate the problem. With the old sun 1.2 -verbose:class did'nt show class unloading but -verbose:gc did. regards. > On a Windows 2000 system with 128M memory using IBM Java 1.3.0 (20010609) > with the JIT on, java.exe's memory usage for this program steadily > increases and performance decreases. Eventually I get an OutOfMemory > message. > > Elapsed time Memory Usage Time to complete 10,000 loops > ------------ ------------ ----------------------------- > 1 minute 26,108 K 31 seconds > 20 minutes 121,696 K 70 seconds > 54 minutes 185,132 K 116 seconds > > A similar memory increase and performance degradation is true running this > program on a Linux Redhat 7.1 system with 256M memory and using IBM Java > 1.3.0 (20010626) with the JIT on. > > However, on a Windows ME system with 64M memory using Sun Java 1.3.1 > (HotSpot), there is no increase in memory usage and no performance > degradation, even after this program has run for 24 hours. > > Here's the code for the SimpleEmbedded Java program that's running: > > import org.python.util.PythonInterpreter; > import org.python.core.*; > > public class SimpleEmbedded { > > public static void main(String []args) throws PyException { > > PythonInterpreter interp = new PythonInterpreter(); > > interp.exec("import time"); > interp.exec("LoopStartTime = time.time()"); > > int i = 1; > while (i > 0) > { > interp.eval("'This is a test'"); > > if (i % 10000 == 0) > { > interp.exec("LoopStopTime = time.time()"); > interp.exec("LoopElapsedSecs = LoopStopTime - > LoopStartTime"); > System.out.println("Completed Loop " + i + > " - elapsed time: " + interp.get("LoopElapsedSecs") + > " secs"); > interp.exec("LoopStartTime = time.time()"); > } > i++; > } > > } > } |