jpype-project / jpype

JPype is cross language bridge to allow Python programs full access to Java class libraries.
http://www.jpype.org
Apache License 2.0
1.12k stars 182 forks source link

Memory Leak??? #949

Open xiaoyu1095 opened 3 years ago

xiaoyu1095 commented 3 years ago

I found a problem with Java wrapper class,such as ...

java code:

import java.util.ArrayList; import java.util.List; public class Runner { public List testListInteger(){ List temp = new ArrayList<>(); for (int i = 0; i < 100000; i++) { temp.add(i); } return temp; } }

python code:

from xxx import Runner def test_run(): runner = Runner() for num in runner.testListInt(): a = num if name == 'main': for i in range(1000000): test_run()

I use the command “top -p pid” to observe the process memory usage, memory usage has been increasing. Only the String will be stable at a certain value. What should I do with it?

magrusch commented 3 years ago

How is the memory usage if you run this in java only? So call testListInteger() recursively a million times in a java function. Paste both measurements (with jpype and with java only). What do you mean with "only string will be stable"? And please paste code in a code block so it's easier to read.