Another memory leak in PImage?
in
Core Library Questions
•
1 year ago
Hello! I have created an application that loads a set of photos and spreads them by separate windows. Each window has 2 rows and 8 columns of photos. By pressing the "right" and "left" buttons, the "window ribbon" may be scrolled left and right. This is done by first preparing two images by drawing them on PGraphics canvas and copying to separate PImages. Then the same PGraphics canvas is used to draw these images progressing their position so as for the "scrolling" effect to occure. All PImage instances are pre-created, and the copy() method is used to cache the right and left window (there images are too drawn with the copy() method to the canvas) because I know that the renderer caches the images and there is a bug in OPENGL renderer that stores them indefinetely. That first bug took me a weak of sweating while trying to find an error in my code. Finally, I was surprised by finding that topic in the internet that says that it is a bug in OPENGL and that OPENGL2 or present P3D would do fine. I have first reimplemented the render through P3D, it was lagging waaaaay toooo muuuuuch! Then I have downloaded Processing 2.04a and used OPENGL2 (which is named just OPENGL there). Same memory leak! It is not huge, but it builds up and lets only about 50 scrollings to be done.
Could anyone comment on that?
Aside from that, I am interested, how would you implement scrolling? I use the pre-draw method because aside from the images, there are also many other things drawn and the effect that I acheive is that they are not drawn while go partially out of the canvas, the PGraphics cuts it out.
EDIT: Please note that all the other things drawn aside from images are not the cause. Since commenting out the single line responsible for drawing the images, eliminates the used heap growth. I use visualjvm to monitor the condition.
1