# PApplet second win exit, create ... RAM overfill

**URL:** <https://discourse.processing.org/t/papplet-second-win-exit-create-ram-overfill/16090>\
**Category:** Coding Questions\
**Created:** [December 3, 2019, 8:35pm UTC](https://discourse.processing.org/t/papplet-second-win-exit-create-ram-overfill/16090 "2019-12-03T20:35:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![GeorgeJava](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/georgejava/32/7646_2.png) [@GeorgeJava](https://discourse.processing.org/u/GeorgeJava)\
**Post date:** [December 3, 2019, 8:35pm UTC](https://discourse.processing.org/t/papplet-second-win-exit-create-ram-overfill/16090/1 "2019-12-03T20:35:28Z")

</div>

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 ?

```auto
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();
  }
}

```

---

<div class="post-metadata">

**Author:** ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)\
**Post date:** [December 4, 2019, 4:08am UTC](https://discourse.processing.org/t/papplet-second-win-exit-create-ram-overfill/16090/2 "2019-12-04T04:08:39Z")

</div>

That‘s even pretty much the same Code :

> [@Closing a second window](https://discourse.processing.org/t/closing-a-second-window/381):
>
> I want to be able to create a second window. The problem is I want the user to be able to close the second window, but doing so closes both the second and main frame. Is there a way I can prevent this? PWindow win; public void settings() { size(320, 240); } void setup() { win = new PWindow(); } void draw() { background(255, 0, 0); fill(255); rect(10, 10, frameCount, 10); } void mousePressed() { println("mousePressed in primary window"); } class PWindow extends PApplet { PWi…

---

<div class="post-metadata">

**Author:** ![GeorgeJava](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/georgejava/32/7646_2.png) [@GeorgeJava](https://discourse.processing.org/u/GeorgeJava)\
**Post date:** [December 4, 2019, 4:34pm UTC](https://discourse.processing.org/t/papplet-second-win-exit-create-ram-overfill/16090/3 "2019-12-04T16:34:23Z")

</div>

Yeah, but no answer, i think…

---

<div class="post-metadata">

**Author:** ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)\
**Post date:** [December 4, 2019, 4:40pm UTC](https://discourse.processing.org/t/papplet-second-win-exit-create-ram-overfill/16090/4 "2019-12-04T16:40:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![GeorgeJava](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/georgejava/32/7646_2.png) [@GeorgeJava](https://discourse.processing.org/u/GeorgeJava)\
**Post date:** [December 4, 2019, 5:22pm UTC](https://discourse.processing.org/t/papplet-second-win-exit-create-ram-overfill/16090/5 "2019-12-04T17:22:16Z")

</div>

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