2

If doing System.exit(1) from a Swing application, are native resources related to the graphics automatically released ? If I add a myFrame.dispose() with myFrame being the sole top-level container in the app, can I be sure not to get the annoying behavoiur seen in some non-java GUI using programs where part of the GUI state will stick frozen to the screen when exiting abruptly ?

2 Answers2

4

Everything owned by a process is released when the process exits, unless you are talking about pathological operating systems like Netware 3 & 4.

user207421
  • 305,947
  • 44
  • 307
  • 483
2
  • Top-Level Containers never GC'ed, because missed method finalize()

  • In this context JFrame.dispose() do nothing, this container is still present in UsedMemory, un_changed, untill current JVM instance exits,

  • you can returns UsedMemerory by removing it contents, notice remove anything from ContentPane, otherwise (RootPane removed) your container stays translucent, only with visible ToolBar and Borders,

  • all Window are always accesible and re_usable, you can test that by Window[] allWindows = Window.getWindows(); throught whole application lifecycle

  • before re_using test container for isDisplayable()

  • everything important here

then

1) don't create lots of Top-Level containers,

2) re_use container that exist

3) only Object that lost all referencies could be GC'ed

Community
  • 1
  • 1
mKorbel
  • 109,525
  • 20
  • 134
  • 319