Thx PhiLho for your reply, I had already checked that thread and another one where you posted your solution, but unfortunately that doesn't work with me.
I don't know if I'm going something very dumb here, but the same code works great on 1.5.1
My setup: I've a class where I create a text (quite big), than I wrote that text in a PGraphics object.
In the main draw, I'm only calling the
drawWord() method that moves horizontally that object.
I'm a creating new words every 10 second. Every time a word is created, a huge amount of memory is allocated and never released.
Here is the code of my class, if you want to have a look
- class SingleWord {
- int WORD_SIZE = 100;
- int wordWitdh;
- int wordHeight;
- PFont wordFont;
- PImage wordImage;
- PGraphics wordImageBuffer;
- float wordImagePosX = 0;
- int wordImagePosY = 30 + (int)random(200);
- float speed = 0.5 + random(1);
- Boolean isStillOnScreen = true;
- SingleWord (String s) {
- wordFont = loadFont("FrutigerLT-LightCn-100.vlw");
- WORD_SIZE = 100;
- speed = 3;
- textFont (wordFont, WORD_SIZE);
- wordWitdh = (int)textWidth (s);
- wordHeight = (int)(WORD_SIZE * 0.75);
- int numLines = 1;
- if (wordWitdh > 400) {
- numLines += wordWitdh / 400;
- wordWitdh = 400;
- }
- wordHeight = (int)(WORD_SIZE * 0.75);
- wordImageBuffer = createGraphics(wordHeight*numLines + (int)(WORD_SIZE*0.25)*numLines + (numLines-1)*(int)(WORD_SIZE*0.25), wordWitdh);
- wordImageBuffer.beginDraw();
- wordImageBuffer.fill (255, 255, 255);
- wordImageBuffer.textFont (wordFont, WORD_SIZE);
- wordImageBuffer.pushMatrix ();
- wordImageBuffer.translate (wordImageBuffer.width, 0);
- wordImageBuffer.rotate (90*3.14/180);
- wordImageBuffer.textAlign(CENTER);
- wordImageBuffer.text(s, 0, 0, wordImageBuffer.height, wordImageBuffer.width);
- wordImageBuffer.popMatrix();
- wordImageBuffer.endDraw ();
- wordImage = wordImageBuffer.get (0,0, wordImageBuffer.width, wordImageBuffer.height);
- }
- void drawWord () {
- if (wordImagePosX < 2720) {
- image (wordImage, wordImagePosX, wordImagePosY);
- }
- else {
- isStillOnScreen = false;
- // HERE I WOULD LIKE TO REMOVE THE RESOURCE
- // cause the word it is out of the screen
-
- }
- }
- }
Any help would be really appreciated, I'm quite lost right now :(