PApplet second win exit, create ... RAM overfill

Helo, i want to exit second window of the PApplet and create another, but i want to clear it absolutely from RAM, becouse its getting takes a lot of RAM, the value getting only higher… how to delete PApplet in all ?

PWindow win;

public void settings() {
  size(300, 300);
}

void setup() { 
  win = new PWindow();

  PApplet.runSketch(new String[] {this.getClass().getSimpleName()}, win);

  surface.setLocation(20, 20);
}

void draw() {
  background(255, 0, 0);
  fill(255);
  rect(10, 10, frameCount, 10);
}

void mousePressed() {
  println("mousePressed in primary window");
  win = new PWindow();
  PApplet.runSketch(new String[] {this.getClass().getSimpleName()}, win);
} 

class PWindow extends PApplet {

  void settings() {
    size(1920, 1028);
  }

  void setup() {
    background(150);
  }

  void draw() {
    ellipse(random(width), random(height), random(50), random(50));
  }

  void mousePressed() {
    println("mousePressed in secondary window");
    exit();
  }

  void exit() {
    dispose();
    surface.setVisible(false);
    System.gc();
  }
}

That‘s even pretty much the same Code :

2 Likes

Yeah, but no answer, i think…

You might want to just keep your second Window open and use noLoop()… that‘s not exactly closing, but better than nothing…

3 Likes

Ok, i keep going with javax swing, i wanted to create a setting windows… :smiley: