Insufficient memory for Java – Sketch on RaspberryPi

I tried this on PC and visualized memory with VisualVM 1.4.3 and it did keep filling memory every time you loaded a new “kick”.

I tried something different and wrote some quick test code:

import ddf.minim.*;
import ddf.minim.ugens.*;
import java.util.Date;

AudioPlayer player;
Minim minim;
AudioOutput out;
AudioSample kickit;

int count;

void setup() 
  {
  size(200, 200);
  minim = new Minim(this);
  out   = minim.getLineOut();
  }

void draw() 
    {
    String songfile;

    if (frameCount%120 == 0)
      {
      if (kickit != null) kickit.close();
      if (count%2 == 0)
        songfile = "1.mp3";
      else
        songfile = "2.mp3";
    
    println("load: " + songfile);

    kickit = minim.loadSample(songfile, 512);    
    kickit.trigger();
    count++;

    println (count);
//    System.gc();
    }
   }

This is what I see with my code:
image

With system.gc() (it is commented out above) it keeps memory in check:
image

:slight_smile:

2 Likes