1

I'm working on a sketch that uses some PGraphics object as buffers that I draw on the screen with the image() method.

My problem is that I've noticed a huge memory leak, 99% due to this buffers not being destroyed properly.

Is there any way to get rid of this objects to free some memory up? I looked on the docs of the old GLGS library and I've tried with the dispose() method, but it doesn't look to have any effect.

genpfault
  • 51,148
  • 11
  • 85
  • 139
Sr.Richie
  • 5,680
  • 5
  • 38
  • 62

2 Answers2

1

Have a look in this post in processing forum, it look like until 2.0b6 there was a leak with PImages. They suggest a hack (below) there...

void draw()
{
  PImage img = createImage(width, height, RGB);
  image(img, 0, 0);
  g.removeCache(img);// this is avoiding the leak
  println(frameCount + " " + g.getCache(img));
}
v.k.
  • 2,826
  • 2
  • 20
  • 29
  • thx a lot for your reply, but unfortunately this doesn't solve my issue, even if it is obviously related... :( – Sr.Richie May 16 '13 at 15:55
  • After posting in forums, I've discovered the fix you proposed it's related to a previous version of processing, not the one I was detailing in the title. I wrote an answer for other people. Thanks for your support anyway :) – Sr.Richie May 17 '13 at 10:20
1

So, after posting in Processing Forum, and thanks to @v.k. answer, I discovered that my problem it's not created by the wrong disposal of PGraphics object.

There was a memory leak about it, but it was fixed in release 2.0b6.

So, if you have a memory leak and you think it's a PGraphics bug, update to 2.0b8 or look better at your code.

Sr.Richie
  • 5,680
  • 5
  • 38
  • 62
  • Great that you found your answer. I edited the post above with the correct beta version. Thanks for pointing that. – v.k. May 17 '13 at 21:53