Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!transit3.readnews.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: Closing/Despose of JFrame Date: Thu, 28 Jun 2012 12:46:07 -0700 (PDT) Organization: http://groups.google.com Lines: 30 Message-ID: References: <5752befc-aca1-46f9-81d9-f3992bf756e7@googlegroups.com> NNTP-Posting-Host: 69.28.149.29 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1340912767 12019 127.0.0.1 (28 Jun 2012 19:46:07 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 28 Jun 2012 19:46:07 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.28.149.29; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T User-Agent: G2/1.0 Xref: csiph.com comp.lang.java.programmer:15730 Stefan Ram wrote: > Stefan Ram writes: > >Jesper Johnsen writes: > >>JFrame frame = new JFrame("Test"); > >public class Main implements java.lang.Runnable > > public class Main implements java.lang.Runnable > { public void run() > { for( ;; ) > { java.lang.System.out.println( java.lang.Runtime.getRuntime().freeMemory() + " Bytes free." ); > javax.swing.JFrame frame = new javax.swing.JFrame(); > frame.pack(); frame.setVisible( true ); frame.dispose(); frame = null; }} > > public static void main( final java.lang.String[] args ) throws java.lang.Throwable > { javax.swing.SwingUtilities.invokeAndWait( new Main() ); }} > > The above program shows declining amounts of free memory for > some time. Then, a gc seems to be triggered, which reclaims > a part of the memory. After several such gcs, there is less > and less memory reclaimed and one feels that soon an > unrecoverable out-of-memory error will happen. But then a > real deep major gc seems to be triggered that seems to > reclaim all or nearly all of the memory! (I stopped it then, > maybe someone wants to have this running overnight?) Also there are answers to other incarnations of this multipost that go into how this all works. -- Lew