Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #1897

Re: Remove JFrame from memory

From Knute Johnson <nospam@knutejohnson.com>
Newsgroups comp.lang.java.help
Subject Re: Remove JFrame from memory
Date 2012-06-28 08:04 -0700
Organization A noiseless patient Spider
Message-ID <jshrp5$kkh$1@dont-email.me> (permalink)
References <84ceeec7-1304-4012-9255-62169dc8dc58@googlegroups.com>

Show all headers | View raw


On 6/28/2012 6:48 AM, Jesper Johnsen wrote:
> How do I remove an object lets say a JFrame from memory?
> I know that the garbage collector handles this - but this simple example does not release itself...
> java.exe uses 10mb in the first wait stage, this increases to 20mb when the JFrame is shown, but the memory usage never returns to the initial 10mb.
> So the garbage collector never removes the object from memory - why?
>
> package jframetest;
>
> import javax.swing.JFrame;
>
> public class JFrameTest {
>
>      public static void main(String[] args) {
>          try{
>          Thread.sleep(5000);
>      }catch(Exception Ex){}
>          JFrame frame = new JFrame("Test");
>          frame.setVisible(true);
>           try{
>          Thread.sleep(5000);
>      }catch(Exception Ex){}
>           frame.setVisible(false);
>           frame.dispose();
>           frame = null;
>      while(1==1){
> try{
>          Thread.sleep(100);
>      }catch(Exception Ex){}
>      }
>      }
>
> }
>

I don't know but it doesn't really matter.  Calling dispose() on it will 
work fine in a real world program.

-- 

Knute Johnson

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Remove JFrame from memory Jesper Johnsen <jsjohnsen.dk@gmail.com> - 2012-06-28 06:48 -0700
  Re: Remove JFrame from memory Knute Johnson <nospam@knutejohnson.com> - 2012-06-28 08:04 -0700
    Re: Remove JFrame from memory "John B. Matthews" <nospam@nospam.invalid> - 2012-06-28 22:02 -0400
  Re: Remove JFrame from memory Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-06-28 11:26 -0400
    Re: Remove JFrame from memory Jesper Johnsen <jsjohnsen.dk@gmail.com> - 2012-06-29 00:58 -0700
      Re: Remove JFrame from memory Lew <lewbloch@gmail.com> - 2012-06-29 13:39 -0700
  Re: Remove JFrame from memory Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-06-28 11:57 -0400
    Re: Remove JFrame from memory Jesper Johnsen <jsjohnsen.dk@gmail.com> - 2012-06-29 01:00 -0700
      Re: Remove JFrame from memory Jesper Johnsen <jsjohnsen.dk@gmail.com> - 2012-06-29 01:03 -0700
        Re: Remove JFrame from memory Lew <lewbloch@gmail.com> - 2012-06-29 13:41 -0700
  Re: Remove JFrame from memory Lew <lewbloch@gmail.com> - 2012-06-28 10:23 -0700
  Re: Remove JFrame from memory Roedy Green <see_website@mindprod.com.invalid> - 2012-06-29 04:05 -0700
    Re: Remove JFrame from memory Lew <lewbloch@gmail.com> - 2012-06-29 13:40 -0700

csiph-web