o java tem um sistema de coletor de lixo(GarbageCollector), o lixeiro literalmente… ele é meio “vadio”, você pode chama-lo a hora que quiser com
“System.gc();”, mas lembre que chamar o GarbageCollector, entenda “sugerir ao jvm que colete o lixo”, mas não quer dizer que ele vá fazê-lo!!
e quando você seta alguma váriavel de referência em Java, com “null” ela se torna qualificada para a coleta de lixo =]
dispose
public void dispose()
Releases all of the native screen resources used by this Window, its subcomponents, and all of its owned children. That is, the resources for these Components will be destroyed, any memory they consume will be returned to the OS, and they will be marked as undisplayable.
The Window and its subcomponents can be made displayable again by rebuilding the native resources with a subsequent call to pack or show. The states of the recreated Window and its subcomponents will be identical to the states of these objects at the point where the Window was disposed (not accounting for additional modifications between those actions).
Note: When the last displayable window within the Java virtual machine (VM) is disposed of, the VM may terminate. See AWT Threading Issues for more information. </blockquote>
já o dispose(), está descrito acima, serve para fechar todos os componentes e memória utilizadas pelo interface gráfica do seu programa…
se eu me equivoquei em algum ponto, me corrijam!
espero ter ajudado!
grato!