destroy

Documentation for this Tk command can be found at: https://www.tcl-lang.org/man/tcl/TkCmd/destroy.htm

destroy ?window? ?window ...?

Destroys each of the windows listed. It is not an error if window does not refer to a non-existent window. Windows to be destroyed may be any type of widget, but since destroy works at the system resource level, things that are not Tk widgets are never destroyed by this command.


The destroy command is used to destroy Tk windows -- not just toplevel windows, it can just as well destroy individual widgets within a window (in which case the not explicitly destroyed siblings continue to exist).


I recently came across a major problem where my application was leaking huge amounts of memory (over 100 MB). I was using the Img extension and I was loading many graphics into memory, but I was not deleting them with image delete. I fixed this problem by binding the close button and the <Destroy> event to a proc which deleted all photos loaded in memory once I was done with them. I learned that before destroying a toplevel, even in Tcl you have to release resources that you are not using anymore ;D

Ro