Re: Closing/Despose of JFrame
Jesper Johnsen <jsjohnsen.dk@gmail.com> writes:
JFrame frame = new JFrame("Test");
public class Main implements java.lang.Runnable
{ public void run()
{ java.lang.Runtime.getRuntime().gc();
try { java.lang.Thread.sleep( 1000 ); } catch( final java.lang.InterruptedException interruptedException ){}
java.lang.System.out.println( java.lang.Runtime.getRuntime().freeMemory() + " Bytes free without JFrame." );
for( int i = 0; i < 999; ++i )
{ java.lang.System.out.println();
javax.swing.JFrame frame = new javax.swing.JFrame();
frame.pack();
frame.setVisible( true );
try { java.lang.Thread.sleep( 1000 ); } catch( final java.lang.InterruptedException interruptedException ){}
java.lang.Runtime.getRuntime().gc();
try { java.lang.Thread.sleep( 1000 ); } catch( final java.lang.InterruptedException interruptedException ){}
java.lang.System.out.println( java.lang.Runtime.getRuntime().freeMemory() + " Bytes free with JFrame." );
frame.dispose();
frame = null;
try { java.lang.Thread.sleep( 1000 ); } catch( final java.lang.InterruptedException interruptedException ){}
try { for( int j = 1; ; j *= 2 )java.lang.String.valueOf( new byte[ j ] ); }catch( final java.lang.Throwable throwable ){}
try { java.lang.Thread.sleep( 1000 ); } catch( final java.lang.InterruptedException interruptedException ){}
java.lang.Runtime.getRuntime().gc();
try { java.lang.Thread.sleep( 1000 ); } catch( final java.lang.InterruptedException interruptedException ){}
java.lang.System.out.println( java.lang.Runtime.getRuntime().freeMemory() + " Bytes free without JFrame." ); }}
public static void main( final java.lang.String[] args )
{ try { javax.swing.SwingUtilities.invokeAndWait( new Main() ); }
catch( final java.lang.InterruptedException interruptedException ){}
catch( final java.lang.reflect.InvocationTargetException invocationTargetException ){} }}
15960272 Bytes free without JFrame.
15653064 Bytes free with JFrame.
15846872 Bytes free without JFrame.
15842304 Bytes free with JFrame.
15860504 Bytes free without JFrame.
15854872 Bytes free with JFrame.
15863136 Bytes free without JFrame.
15858568 Bytes free with JFrame.
15862568 Bytes free without JFrame.
15858000 Bytes free with JFrame.
15859232 Bytes free without JFrame.
15853240 Bytes free with JFrame.
15853808 Bytes free without JFrame.
15849240 Bytes free with JFrame.
15849720 Bytes free without JFrame.
15844040 Bytes free with JFrame.
15844560 Bytes free without JFrame.
15839992 Bytes free with JFrame.
15840472 Bytes free without JFrame.
15835904 Bytes free with JFrame.
15836384 Bytes free without JFrame.
15831720 Bytes free with JFrame.
15832256 Bytes free without JFrame.
15820216 Bytes free with JFrame.
....