For memory leaks in java, you can look at batch processing. I did not find a great solution for processing other than starting
top -s 5
(on Unix systems) and monitor memory usage until it freezes. I recently worked on a datavis project where I created potentially thousands of blitts (in my case, text images for use in opengl) in an ArrayList. Initially, I recreated these arrays on the fly every time I downloaded data, and this contributed to a memory leak.
In my case, I tried to exclude object references and call the garbage collector. I think this may be due to the fact that the processing calls your void draw () method potentially 60+ times per second, but it seems like it never skipped links.
What I did to fix the problem was to load all the images / create blits only once in the setup () method and only add new elements to the ArrayList when new data appeared.
Before that, I would simply recreate the entire ArrayList on the fly, because it seemed fast enough, but with a long run of this terrible memory leak problem.
Now I just got blit assigned to this link, and not every time I created a new object and an ArrayList. It was much more efficient and did not suffer from the same memory problem.
For example, something like this (runs thousands of times in a loop):
tempImage = imageArrayList.get(i);
instead of the following:
tempImage = loadImage("image.jpg"); // this creates a new object every time it is called
source share