The setVisible method does not free memory resources and should be used only when the form should be used again.
The dispose method Releases all resources on the native screen used by this window, its subcomponents, and all its child users. That is, the resources for these Components will be destroyed, any memory that they consume will be returned to the OS, and they will be marked as not displayed.
Edgard leal
source share