PGraphics Memory Leaks

Greetings,

I am writing a GUI from my artificial neural networks and Darwinist machine learning project, which involves using PGraphics as the "screens". This is to allow me flexibly in how I manipulate the scene. But there has been a memory leak.

I'm assuming this is a bug as I can't find any reason for this to happen, and it has been plaguing me for a while now. I simply cannot find a solution, I tried. The issue reports have nothing open, and the same issues that were posted are now closed, solved, and apparently fixed. I wanted to come here and see what the community knows about it, and their potential solutions, otherwise I will file this as a core issue, and it will have to be re-opened.

For some reason even the most basic PGraphics object will cause a memory leak, as the below code can demonstrate. I have tried g.removeCache(); however this simply caused huge amounts of "leakage" when that operation was performed strangely enough. It is turning the object null however as you can see in the code. Sadly that was the only solution I could find. Apparently this did not happen in 1.5.x

Tested on Linux, and Windows, with graphics card and without, and on a separate computer as well. The leak persist.

Thank-you

void setup()
{
  frameRate(60);
  size(640, 480, P3D);
  screen = createGraphics(width/2, height/2, P3D);
}

void draw()
{
  background(#0C1018);
  screen.beginDraw();
  screen.background(#00FFFF);
  screen.endDraw();
  image(screen, 0, 0);
  /*println(g.getCache(screen)); //prints processing.opengl.Texture@whatever
  g.removeCache(screen);
  println(g.getCache(screen)); //prints null
  println();*/
}

OS: Ubuntu 14.04 LTS OS type: 64-bit Processor: AMD A8-5500 APU with Radeon(tm) HD Graphics × 4 Graphics: Gallium 0.4 on AMD CAICOS

Answers

  • What Processing version are you using? Running the above code I could not reproduce a memory leak in 3.0.2

  • 3.0.2 my bad.

    Crud.

  • edited April 2016

    It does on all my versions. I'll get a friend to run it on his system later as well to check.

    Also it seems to be significantly slower in 2.2.1.

  • I ran a few samples and found that in 2.2.1, 3.0b4, 3.0.1 the memory leaks slowly, but still goes up with time. In 3.0.2, it goes up what seems ten times faster.

  • Can you describe how fast? On my system I see a bit of variation in memory usage with Processing, by default it uses about 120 MB of RAM with about 10 MB variation in this with a relatively slow frequency (which could be a small memory leak). But nothing huge like what would happen if you called createGraphics() in draw()... Maybe my processor is just better at garbage collecting? In my experience Processing has always been a bit harder on the processor than other programs...

  • Well I can't say. It would seem to be slightly different every time. For example I'm running right now and it is going up, but very very slowly. Like it hasn't jumped up in minutes. As well, I am running it side by side with a simple image() example, and it would seem that the image function is the problem. I am about to go search the forum and bugs reports for possible more info.

Sign In or Register to comment.