<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with #memoryleak - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=%23memoryleak</link>
      <pubDate>Sun, 08 Aug 2021 17:55:14 +0000</pubDate>
         <description>Tagged with #memoryleak - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/tagged%23memoryleak/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>out of memory error on loadImage() in Draw loop</title>
      <link>https://forum.processing.org/two/discussion/27810/out-of-memory-error-on-loadimage-in-draw-loop</link>
      <pubDate>Fri, 20 Apr 2018 21:30:06 +0000</pubDate>
      <dc:creator>jeffmarc</dc:creator>
      <guid isPermaLink="false">27810@/two/discussions</guid>
      <description><![CDATA[<p>So the Java garbage collection and memory management works in the background .
In post from 2016 from Henri , "PImage won't release memopry"
KevinWorkman says the Java garbage collection and memory management works in the background so "Out of Memory"
error should never happen.
Wonder if it is fixed in later versions or what cause I get it in  the following scenerio.</p>

<pre><code>Using 2.2.1 and getting out of memory when i run sketch. basically it asks the user to grab an image. The image is then loaded with loadImage() After 1000's of draw loops , i get out of memory and sketch halts with error messages in console. Is the auto memory management in Java the same in this version or better in later versions of Processing? The program uses an event counter to allow only one iteration of each condition in the draw loop. 

  Step 1 - wait for user to request image grab 
  Step 2 - loadImage and display with image() 
  Step 3- perform image processing 
  Step 4- report numeric results ( count all pixels below threshold) 
  Reset event counter to 1

  I inserted a wait time of 1 second to auto initiate the loop and it runs for hours and finally gives out of memory 
 So is the garbage collector not working in theis version or what?
</code></pre>

<p>Thanks</p>
]]></description>
   </item>
   <item>
      <title>Can't release PImage memory!</title>
      <link>https://forum.processing.org/two/discussion/18762/can-t-release-pimage-memory</link>
      <pubDate>Fri, 28 Oct 2016 04:40:57 +0000</pubDate>
      <dc:creator>Henri</dc:creator>
      <guid isPermaLink="false">18762@/two/discussions</guid>
      <description><![CDATA[<p>For some reason every image i use on my sketch stays in memory untill i close the sketch. Even if i null-reference all of the variables, the Garbage Collection can't release them.</p>

<p>I've came across with a lot of forum posts about it and all suggested <code>g.removeCache( PImage)</code> but this doesn't work. Also, even if i don't use <code>image()</code> in my sketch, it still consumes a lot of memory. Just comment it out and you will see that <code>loadImage()</code> puts the image on the Heap Memory and even if you null reference the <em>img</em> variable it will not make a difference in the memory usage.</p>

<p>(for this sketch i'm using an 40mb .png i've created in mspaint)</p>

<pre><code>`PImage img;

void setup() {
    size(200, 200);
    img = loadImage("big.png");
}

void draw() {
    clear();

    if(img!=null){
      image(img, 0, 0);
      g.removeCache( img );
      img = null;
      println("cleaned");
    };
    System.gc();

}

void keyPressed(){
   if(key=='q'){
     g.removeCache( img );
     img = null;
   }
} `
</code></pre>

<p>Also, <code>System.gc()</code> doesn't work. How can i release those images from the memory?</p>
]]></description>
   </item>
   <item>
      <title>Weird memory usage</title>
      <link>https://forum.processing.org/two/discussion/27768/weird-memory-usage</link>
      <pubDate>Sun, 15 Apr 2018 06:15:46 +0000</pubDate>
      <dc:creator>robotman2412</dc:creator>
      <guid isPermaLink="false">27768@/two/discussions</guid>
      <description><![CDATA[<p>i'm making a Universal Turing machine emulator (google it).</p>

<p>it uses ever increasing amounts of memory, not much more to say.</p>

<p>it obviously shouldn't</p>

<p><a rel="nofollow" href="https://pastebin.com/ZNKADezL">https://pastebin.com/ZNKADezL</a> turingmachine.pde</p>

<p><a rel="nofollow" href="https://pastebin.com/isBwGXmD">https://pastebin.com/isBwGXmD</a> GUI.pde (currently unused)</p>

<p><a rel="nofollow" href="https://pastebin.com/guddfXsM">https://pastebin.com/guddfXsM</a> computation.pde</p>

<p><a rel="nofollow" href="https://pastebin.com/nms3733V">https://pastebin.com/nms3733V</a> data.pde</p>

<p>if you look in the main file there is a PGraphics called p.</p>

<p>when i use this to animate writing, the memory usage goes skyhigh, eventually chrashing.</p>

<p>i can't use it for any longer than three minutes like this.</p>
]]></description>
   </item>
   <item>
      <title>PShape rotations and translations increase memory used (used heap and heap size) with time</title>
      <link>https://forum.processing.org/two/discussion/26651/pshape-rotations-and-translations-increase-memory-used-used-heap-and-heap-size-with-time</link>
      <pubDate>Mon, 05 Mar 2018 03:20:44 +0000</pubDate>
      <dc:creator>GLV</dc:creator>
      <guid isPermaLink="false">26651@/two/discussions</guid>
      <description><![CDATA[<p>I created some cool planetary gears with vectors and shapes (not PShapes) with success!</p>

<p>Demo here:
<a rel="nofollow" href="https://youtu.be/RTZvgVu4LeU">https://youtu.be/RTZvgVu4LeU</a></p>

<p>I tried replacing the gear shapes with PShapes and when I do rotations or translations the memory used (used heap and heap size) keeps growing!</p>

<p>I used Visual VM to monitor and included a screen grab.</p>

<p>Why does memory grow when I rotate or translate PShapes? Is this a memory leak?
Seems fine if I comment out the translations and rotations.</p>

<p>Sample code is something I was testing and a demo of growing heap:</p>

<pre><code>// Author:      GLV
// Date:        2018-03-04
// Version:     04

PShape s2;
int time_start;
PVector v1;

void settings()
  {
  size(600, 600, P2D);
  }

void setup()
  { 
  s2 = createShape();
  s2.beginShape();
  fill(102);
  stroke(255);
  strokeWeight(0);
  s2.vertex(0, 0);
  s2.vertex(0, 20);
  s2.vertex(20, 20);
  s2.vertex(20, 0);
  s2.endShape(CLOSE); 
  time_start = millis();
  v1 = new PVector(0, 0);
  }

void draw()
  {
  background(0);  
  translate(width/2, height/2);
  float radius = 20*2*40/TAU;  // radius for equal spacing of teeth
  noFill();
  strokeWeight(3);
  ellipse(0, 0, 2*radius, 2*radius);
  v1.set(0, 20*2*40/TAU);       
  for (int i=0; i&lt;=40; i++)
    { 
    fill(255, 255, 0);
    v1.rotate(TAU/40);     
    s2.translate(-10, -10);    //Comment this line
    s2.rotate(v1.heading());   //Comment this line
    shape(s2, v1.x, v1.y); 
    s2.rotate(-v1.heading());  //Comment this line
    s2.translate(10, 10);         //Comment this line
    }    

    if((millis()-time_start) &gt;= 10000)
      {
//      System.gc();
//      Runtime.getRuntime().gc();  
      time_start = millis();
      println("Garbage Collection");
      } 
    }
</code></pre>

<p><img src="https://forum.processing.org/two/uploads/imageupload/367/H2ESCWWEW5GU.PNG" alt="Capture" title="Capture" /></p>
]]></description>
   </item>
   <item>
      <title>memory leak</title>
      <link>https://forum.processing.org/two/discussion/26212/memory-leak</link>
      <pubDate>Thu, 01 Feb 2018 21:06:36 +0000</pubDate>
      <dc:creator>LaxOfBayDay</dc:creator>
      <guid isPermaLink="false">26212@/two/discussions</guid>
      <description><![CDATA[<p>My app has a memory leak. I'm a noobie and I've been struggling to figure out how to plug it.</p>

<p>The following code is what is highlighted when I get the out of memory error:</p>

<pre><code>instText.clear(); 
instText.add(loadImage(dataPath(textName)));
</code></pre>

<p>It's contained in a conditional and loads a different image every time I press a button. I tried to change it to.</p>

<pre><code>instText.clear(); 
System.gc();
instText.add(loadImage(dataPath(textName)));
</code></pre>

<p>But I still got a memory error. Any advice would be appreciated.</p>
]]></description>
   </item>
   <item>
      <title>Gif Animation Library - Still having memory leaks</title>
      <link>https://forum.processing.org/two/discussion/26132/gif-animation-library-still-having-memory-leaks</link>
      <pubDate>Fri, 26 Jan 2018 17:09:29 +0000</pubDate>
      <dc:creator>fleetfox</dc:creator>
      <guid isPermaLink="false">26132@/two/discussions</guid>
      <description><![CDATA[<p>Hi,
I already asked this as a new post in an old discussion from two years ago, but as expected nobody answered! ;) So I try my luck again:</p>

<p>I would like to build a wooden frame with a display that shows gifs and jpgs when it is activated by a touch sensor. I am using an Up core board with win10 for this which really is a nice piece of hardware. I am using the gif library from 01010101's github account, which seems to be the newest version (<a href="https://github.com/01010101/GifAnimation" target="_blank" rel="nofollow">https://github.com/01010101/GifAnimation</a>) and works with processing 3.
Unfortunately this library seems to have a memory leak problem as already discussed in here: <a href="https://forum.processing.org/two/discussion/12452/animated-gif-slideshow" target="_blank" rel="nofollow">https://forum.processing.org/two/discussion/12452/animated-gif-slideshow</a>
To be honest this discussion did not help me to fix the memory leak problem with this library. I still get the error message after several gifs are shown. This is my test code I am using to explore possible solutions:</p>

<pre><code>import gifAnimation.*;

Gif myGif;
String[] filenames;
String path;

void setup() {

  fullScreen(P2D);
  frameRate(25);
  imageMode(CENTER);
  path = sketchPath();   
  path = path+"\\files\\GifDiv";       
  filenames = listFileNames(path);
  myGif = new Gif(this, path+"\\"+filenames[int(random(0,filenames.length)-1)]);

}

void draw() {

    if (frameCount == 1 ){
      myGif = new Gif(this, path+"\\"+filenames[int(random(0,filenames.length)-1)]);
      myGif.play();
      println(frameCount);
      println("first Play");
      image(myGif, displayWidth/2, displayHeight/2, myGif.width , myGif.height);    
    } else if (frameCount % 40 == 0){
      myGif.stop();
      myGif.dispose();     
      myGif = null;
      background(0);
      println(frameCount);
      println("clear Cache");
  } else if (frameCount % 40 == 1){
      myGif = new Gif(this, path+"\\"+filenames[int(random(0,filenames.length)-1)]);
      myGif.play();
      println(frameCount);
      println("new Play");
      image(myGif, displayWidth/2, displayHeight/2, myGif.width , myGif.height);
  } else{
    println(frameCount+" just Counting Frames");
    image(myGif, displayWidth/2, displayHeight/2, myGif.width , myGif.height);
  }

}

String[] listFileNames(String dir) {
  File file = new File(dir);
  if (file.isDirectory()) {
    String names[] = file.list();
    return names;
  } else {
    // If it's not a directory
    return null;
  }
}
</code></pre>

<p>The code might seem odd, but I wanted to test what happens when at one frame in time no gif is shown, disposed and set to null. My hope was that in this moment the memory would be cleared. It wasn't!!
The source of this problem might be the libraries dispose() command, which might not totally clear the memory!?  But this is the point where it ends for me as I am too stupid to write pure Java-Code, possibly fix this and compile another version of the library. So my hope is to find somebody here who is library coder and might be willing to help!</p>

<p>Best,
Tim</p>
]]></description>
   </item>
   <item>
      <title>Memory isn't freed when I close my program</title>
      <link>https://forum.processing.org/two/discussion/25364/memory-isn-t-freed-when-i-close-my-program</link>
      <pubDate>Sun, 03 Dec 2017 22:00:05 +0000</pubDate>
      <dc:creator>Tdlego</dc:creator>
      <guid isPermaLink="false">25364@/two/discussions</guid>
      <description><![CDATA[<p>Hello,
I'm currently programming a little game and for that i need to load some image and musics that will be used very often. The fact is that i got two problem:
- When the program close, no matter the reason, the memory isn't freed and so every time i run it uses more and more ram. 
   For example i can't run it more that two times without manually killing the process in windows which is a bit frustrating 
   when i must fix 50 bugs or so.
- The other problem is that processing with python uses a lot of memory compared to the total size of the file that i load:
   2.5 giga of ram for only 40mb of assets.
I don't know if i have to post my code because nobody would have the patience to read 380 lines of it. But if you want to see it i can give it.
Finally, i hope those issues are fixable and sorry for my bad english, i'm french.</p>
]]></description>
   </item>
   <item>
      <title>How to fix memory leak caused by PGraphics?</title>
      <link>https://forum.processing.org/two/discussion/22988/how-to-fix-memory-leak-caused-by-pgraphics</link>
      <pubDate>Thu, 08 Jun 2017 13:35:52 +0000</pubDate>
      <dc:creator>akiva42</dc:creator>
      <guid isPermaLink="false">22988@/two/discussions</guid>
      <description><![CDATA[<p>My program uses the PGraphics object as a buffer to create graphics before drawing to the screen. After running my program for about 20 minuets it crashes. Looking at the system memory use it looks like this is caused by and out of memory error. Interestingly this seems to only happen when I build the application (not running from the editor).</p>

<p>After reading this post <a href="https://forum.processing.org/one/topic/pimage-memory-leak-example.html#25080000001807951" target="_blank" rel="nofollow">https://forum.processing.org/one/topic/pimage-memory-leak-example.html#25080000001807951</a> and some more that also reference the g.removeCache(img); solution I tired it out. I think it's clearing the cache, but it's causing only black to be drawn to the screen.</p>

<p>A section of my code:</p>

<p><code>public void drawRoute() {
    tint(255, myAlpha);
    image(myPg, 0, 0);
    g.removeCache(myPg);
    noTint();
  }</code></p>

<p>I'm calling drawRoute() directly from the main draw().</p>

<p>What am I doing wrong? Is this fix still relevant for processing 3.3.4?</p>

<p>Thanks</p>
]]></description>
   </item>
   <item>
      <title>PVector causing memory usage</title>
      <link>https://forum.processing.org/two/discussion/21927/pvector-causing-memory-usage</link>
      <pubDate>Mon, 10 Apr 2017 22:08:36 +0000</pubDate>
      <dc:creator>geek96boolean10</dc:creator>
      <guid isPermaLink="false">21927@/two/discussions</guid>
      <description><![CDATA[<p>Using VisualVM, I found that the largest consumer of memory appears to be PVectors. As per my previous topic, my animation rendering sketch draws nearly 200 boxes per frame, and a single animation sequence could be as many as 200k frames. This means I rapidly hit the memory usage limit, even after adjusting Processing to allow up to 8GB of memory to be allocated.</p>

<p>The following image is of a sketch's heap that simply involves drawing a box every draw() call.
<img src="http://orig03.deviantart.net/1aa3/f/2017/100/d/d/procheap_by_geek96boolean10-db5cw1u.png" alt="" /></p>

<p>Now imagine that 200x as bad. The dip is the GC working; unfortunately, it can't quite keep up with the full sketch.</p>

<p>Is anyone having this sort of issue?</p>

<p>It appears that this isn't the only contributor of memory use, but it accounts for the largest portion.
(Actual sketch data)
<img src="http://orig08.deviantart.net/1b6c/f/2017/100/9/8/procheap2_by_geek96boolean10-db5cx0i.png" alt="" /></p>

<p>This is really bad.</p>
]]></description>
   </item>
   <item>
      <title>PShape Memory Leak - Garbage Collection Pauses</title>
      <link>https://forum.processing.org/two/discussion/1202/pshape-memory-leak-garbage-collection-pauses</link>
      <pubDate>Tue, 12 Nov 2013 08:00:01 +0000</pubDate>
      <dc:creator>Sama</dc:creator>
      <guid isPermaLink="false">1202@/two/discussions</guid>
      <description><![CDATA[<p>It seems that PShapes don't get removed from the memory and instead build up causing long garbage collection / relocation times.</p>

<p>Below is an example of this. The pauses are garbage collections.</p>

<pre><code>void setup () {
   size (200,400,P2D); 
}

void draw() {

  PShape newCells;
     newCells = createShape();  
       newCells.beginShape(TRIANGLES);

         for (int i = 0; i &lt;  2000; i++) {
                newCells.vertex(random(0,width),random(0,height));
                newCells.vertex(random(0,width),random(0,height));
                newCells.vertex(random(0,width),random(0,height));
         }
       newCells.endShape();   

       shape(newCells, 0,0);
 }
</code></pre>

<p>I have looked at the garbage collections in VisualVM and it builds up very quickly and moves memory to Old gen.</p>

<p>The same <strong>doesn't</strong> happen with immediate mode (no PShape)</p>

<p>My questions are:</p>

<p>1) Is this a bug?</p>

<p>2) Would changing GC options help, if so how do you set this up on mac, I am a total novice with Terminal</p>

<p>Edit: Just to clarify, it is clear this is not the way to use PShape, in the context immediate mode or PShape(Group) is appropriate. But my problem is I need to create the shapes in real time, with thousands of triangle each frames, and then repeat the geometry in a mandala (radial symmetry) form.</p>
]]></description>
   </item>
   <item>
      <title>There is some sort of memory leak in my code?</title>
      <link>https://forum.processing.org/two/discussion/17215/there-is-some-sort-of-memory-leak-in-my-code</link>
      <pubDate>Sun, 19 Jun 2016 15:41:28 +0000</pubDate>
      <dc:creator>vanmoonshine</dc:creator>
      <guid isPermaLink="false">17215@/two/discussions</guid>
      <description><![CDATA[<p><a rel="nofollow" href="http://stackoverflow.com/questions/37893106/game-slows-down-after-a-while-potential-data-leak">stackoverflow.com/questions/37893106/game-slows-down-after-a-while-potential-data-leak</a></p>

<p>Here is the original post, essentially I'm trying to make a game with p5 and p5.play but don't see why it is slowing down after 30 seconds of run time. If anyone here knows how to detect collisions on certain sides of a sprite that would be very useful as well. (IE if I have a player sprite that is being squished on top and bottom by two block sprites how would I detect such a thing). Thanks in advance!</p>
]]></description>
   </item>
   <item>
      <title>Memory leak or misunderstanding? (IPCapture)</title>
      <link>https://forum.processing.org/two/discussion/17093/memory-leak-or-misunderstanding-ipcapture</link>
      <pubDate>Fri, 10 Jun 2016 19:31:21 +0000</pubDate>
      <dc:creator>tohox</dc:creator>
      <guid isPermaLink="false">17093@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>The program below grabs frames from an MJPEG camera stuffs them in a circular buffer and displays them with a predefined delay.</p>

<p>While visually this behaves as expected the problem I have is that memory usage continuously increases while the program runs and eventually stops when it reaches the limit.</p>

<p>The IPcapture library example grabs the frames by reading the cam1 instance directly as so:
buffer[x] = cam1;</p>

<p>But I've had to change this slightly because it would always show the last frame regardless of where in the buffer I was reading from. My guess is that assigning this way is similar to using a pointer to the actual IPcapture object and not a copy of its image data. So I did this instead:
buffer[x] = cam1.get();</p>

<p>This works as expected making a copy of the frame and storing it in the PImage buffer. The problem I have then is that it seems to be making a copy of the whole IPcapture object and not just the image data taking up more memory every time I copy it to the buffer.</p>

<p>Is this a problem with the way the library works or am I not doing this properly? Any input appreciated. Thanks!</p>

<pre><code>import ipcapture.*;

IPCapture cam1;

// Circular buffer
PImage[] cam1_buffer; 

// This determines the size of the circular buffe
int nFrames = 500;
// These are used to iterate through the buffer while writing and reading
// the read counter should always be at least one frame ahead of the write counter
int iWrite = 0, iRead = 1;

void setup() {
  fullScreen();

  // Set the cam's URL and start it
  cam1 = new IPCapture(this, "http://" + "192.168.0.251:88/cgi-bin/CGIStream.cgi?cmd=GetMJStream&amp;usr=root&amp;pwd=root", "root", "root");
  cam1.start();
  cam1.pixelWidth = 640;
  cam1.pixelHeight = 480;

  // Declare a frame buffer sized accordingly to our desired number of frames
  cam1_buffer = new PImage[nFrames];
}

void draw() {
  // Gets a frame from the camera and store it in our buffer 
  if (cam1.isAvailable()) {
    cam1.read();
    cam1_buffer[iWrite] = cam1.get();
    // Reads a frame from our buffer
    if(cam1_buffer[iRead] == null){
      // Display this text if the buffer isn't full yet.
      clear();
      fill(255);
      text("BUFFERING " + str(iWrite) +" / " + str(nFrames),300,10);
    }
    else{
      // Here we display our delayed frames
      image(cam1_buffer[iRead],0,0);
    }    

    // Increment write and read counters
    iWrite++;
    iRead++;

    // Start writing over the begining of our buffer every time we reach the end
    if(iRead &gt;= nFrames-1){
      iRead = 0;
    }

    if(iWrite &gt;= nFrames-1){
      iWrite = 0;
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Possible Memory Leak?</title>
      <link>https://forum.processing.org/two/discussion/16362/possible-memory-leak</link>
      <pubDate>Sat, 30 Apr 2016 16:28:09 +0000</pubDate>
      <dc:creator>iGoodie</dc:creator>
      <guid isPermaLink="false">16362@/two/discussions</guid>
      <description><![CDATA[<p>Hello everybody, I'm using Proclipsing.
First of all, do you guys recommend using Proclipsing, if not where can I find the Processing3 jars to attach in my Eclipse project?</p>

<p>The other thing is that I made a little UI system which disposes and resets itself in every Stage Change action. Since every Stage has it's own PImage instances (such as logos, button state images etc), every setup of UI according to that Stage loads up new PImages. I read a lot about memory leak with image() method and PImage in the old versions of Processing. I am not sure if Proclipsing has that leak bug fixed or I'm doing some disposing wrong or even possibly Task Manager measuring it awkwardly wrong. Also I'm not sure which part of my project should I post here in order to clarify that case, since the problem has a weird concept behind it.
I'm looking forward to your replies, thanks in advance</p>
]]></description>
   </item>
   <item>
      <title>PGraphics Memory Leaks</title>
      <link>https://forum.processing.org/two/discussion/16071/pgraphics-memory-leaks</link>
      <pubDate>Sun, 17 Apr 2016 21:16:45 +0000</pubDate>
      <dc:creator>MadScience2728</dc:creator>
      <guid isPermaLink="false">16071@/two/discussions</guid>
      <description><![CDATA[<p>Greetings,</p>

<p>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.</p>

<p>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.</p>

<p>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 <em>is</em> 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</p>

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

<p>Thank-you</p>

<pre><code>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();*/
}
</code></pre>

<p>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</p>
]]></description>
   </item>
   <item>
      <title>looping video,  sketch slowing down</title>
      <link>https://forum.processing.org/two/discussion/15384/looping-video-sketch-slowing-down</link>
      <pubDate>Wed, 09 Mar 2016 18:05:38 +0000</pubDate>
      <dc:creator>AshaSato</dc:creator>
      <guid isPermaLink="false">15384@/two/discussions</guid>
      <description><![CDATA[<p>Hello! 
I have a sketch-in-progress which reads in some items from a tsv file in order to display a video on loop and two alternate labels for it, in a randomised order. There are 16 videos. Each video is consecutively loaded into the same variable 'stimulus', via a function getTrial() which is called once in setup() and then once every time a choice of label is made via the keyPressed() function - so the user makes a choice, and the next movie is loaded in.</p>

<p>I thought that if I loaded the new video into the same variable, the old one would be cleared from memory, but after the first three or four videos, my sketch starts slowing down and gets slower and slower with each trial. I've also tried doing stimulus = null; before loading in the new video, but it doesn't seem to make a difference.</p>

<p>The sketch only slows down if the video is set to loop, but if I never pick a label the first video continues looping without slowing down.</p>

<p>Any ideas what is happening? I'm pasting in the whole sketch, in case the issue is something else. Maybe I should be calling stimulus.loop() somewhere else?</p>

<pre><code>import processing.video.*;



Table stims;
int[] trialList;
int trials; 
int trialno; 
int currentTrial; 

int choice;
boolean choicemade; 

Movie stimulus;
String mov;
String target;
String distractor;
int veridical;

void setup () {
  size(512, 800);
  textAlign(CENTER);
  imageMode(CENTER);
  stims = loadTable("iconic_condition.txt", "header,tsv");
  trialno = 0;
  currentTrial = int(random(stims.getRowCount()));
  getTrial(currentTrial);
  choicemade = false;
}


void draw() {
  background(255);
  //draw stimulus and options
  fill(0);
  image(stimulus, width*0.5, height*0.25, 400*1.25, 400);
  text(mov+" veridical: "+veridical, width*0.5, height*0.25);
  text(target, width*0.25, height*0.5);
  text(distractor, width*0.75, height*0.5);

  //update trial info or exit
  if (choicemade) {
    if (trialno == 16) {
      exit();
    } else
      getTrial(currentTrial);
    choicemade = false;
  }
}




void keyReleased() {
  if (key == '1') {
    choicemade = true;
    choice = 1;
    println(trialno+"\t"+ mov + "\t" + target +"\t" + distractor +"\t" +  veridical + "\t" +choice );
    trialno += 1;
    stims.removeRow(currentTrial); //delete completed trial from table
    currentTrial = int(random(stims.getRowCount())); //pick new trial
    getTrial(currentTrial);
  } else if (key == '2' ) {
    choice = 2;
    println(trialno+"\t"+ mov + "\t" + target +"\t" + distractor +"\t" +  veridical + "\t" +choice );
    choicemade = true;
    trialno +=1;
    stims.removeRow(currentTrial); //delete completed trial from table
    currentTrial = int(random(stims.getRowCount())); //pick new trial
    getTrial(currentTrial);
  }
}

//gets variable values for current trial
void getTrial(int currentTrial) {
  if (trialno &gt; 15) {
    exit();
  } else {
    //get all info for current trial:
    mov = stims.getString(currentTrial, "mov");
    stimulus = null; //this doesn't seem to make a difference
    stimulus = new Movie(this, "Stims/"+mov);
    stimulus.loop();
    target = stims.getString(currentTrial, "target");
    distractor = stims.getString(currentTrial, "distractor");
    veridical = stims.getInt(currentTrial, "ver"); //condition - 1 = veridical, 0 = fake
  }
}


//shuffling an int list
void shuff(int[] shufflebag) {
  int current;
  for (int i= 0; i &lt; shufflebag.length; i++) {
    int selection = int(random(shufflebag.length)); //random index
    current = shufflebag[i]; // current index
    //swaps current and selected
    shufflebag[i] = shufflebag[selection]; // value @ selected index goes into current index
    shufflebag[selection] = current; //value of current index goes into selected index
  }
}


void movieEvent(Movie m) {
  m.read();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>running sound.play more than 20 times slows browser to a crawl</title>
      <link>https://forum.processing.org/two/discussion/14223/running-sound-play-more-than-20-times-slows-browser-to-a-crawl</link>
      <pubDate>Sat, 02 Jan 2016 07:16:03 +0000</pubDate>
      <dc:creator>brig</dc:creator>
      <guid isPermaLink="false">14223@/two/discussions</guid>
      <description><![CDATA[<p>Hallo.
Just wondering if there's a trick to get multiple sound effects to play at once. I'm playing the same sound effect one time every time a creature hits a wall (which happens a lot). Even though the sound effect is less than a second, after about 20 sound.plays, FireFox slows to a crawl... even after all of sounds have stopped playing. It's like all the memory gets eaten up and is not released. I'm figuring there's some kind of memory release I need to specify?</p>

<p>thx.</p>
]]></description>
   </item>
   <item>
      <title>Memory Management - App eating my ram</title>
      <link>https://forum.processing.org/two/discussion/7837/memory-management-app-eating-my-ram</link>
      <pubDate>Mon, 27 Oct 2014 19:10:49 +0000</pubDate>
      <dc:creator>WIL993</dc:creator>
      <guid isPermaLink="false">7837@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I have built an application that uses image sequences, my issue is however, that the application is very memory hungry. It works pretty well on the iMac I have been developing on however when I try to run it on a mac mini (2012) which is where it will need to run, it is unusable because of lag.</p>

<p>Are there ways to optimize memory management or clear the cache etc so that the memory does not get clogged up?</p>

<p>(I have already upped the RAM in preferences to 4gb) Even on my desktop which is technically far better spec that the iMac I have serious issues with frame rates and RAM usage.</p>

<p>Any help is much appreciated!
Will</p>
]]></description>
   </item>
   <item>
      <title>Severe framerate drop problem</title>
      <link>https://forum.processing.org/two/discussion/4372/severe-framerate-drop-problem</link>
      <pubDate>Mon, 14 Apr 2014 10:35:29 +0000</pubDate>
      <dc:creator>Matthewdk54</dc:creator>
      <guid isPermaLink="false">4372@/two/discussions</guid>
      <description><![CDATA[<p>Hi web,</p>

<p>I have created a simple animation with the processing but when I run it as a processing.js embedded html canvas it drops below 10fps.</p>

<p>I understand its relative to a problem with my call looping and memory concurrency, but I am not an expert on how to cap my code so its more efficient when loaded and run through a web browser.</p>

<p>If you can look at it and let me know where I could improve, I'll be grateful for your web advice.</p>

<blockquote class="Quote">
  <p>float r;
  float theta;
  float theta_vel;
  float theta_acc;
  float max_distance;</p>
</blockquote>

<p>void setup() {
  frameRate(30);</p>

<pre><code>r = 250;
theta = 0;
theta_vel = .04;
theta_acc = 0;
</code></pre>

<p>size(400,400,P3D);</p>

<p>max_distance = dist(0, 0, width, height);
}</p>

<p>void draw() {
  background(0,0);
  //lights();
  rotateX(.66);</p>

<p>translate(180,240);
  for(int i = 0; i &lt;= width/7; i += 3) {
  for(int j = 0; j &lt;= width/7; j += 3) {
  float size = random(dist(random(100,200), random(100,200), i, j));
      size = size/max_distance * 410;
          pushMatrix();
          translate(i, j);
          float c = map(size, 0, 255, 0, 255);
          fill(255, c, c);</p>

<pre><code>      box(17,7,size);
      popMatrix();
  }
}
theta_vel += theta_acc;
theta += theta_vel;
</code></pre>

<p>}</p>

<blockquote class="Quote">
  
</blockquote>
]]></description>
   </item>
   </channel>
</rss>