It doesn't, with rare exceptions. [[Details.]] [TCT] takes memory leaks [[ref]] very seriously. Few ever escape into a release, and few known ones survive long. '''However''', there are at least an order of magnitude more ''perceived'' memory leaks. These result mainly from causes such as: * mis-measured memory use * userland, or application-level, memory leaks. * system or underlying language libraries (like libc for the C implementation of Tcl) An example of what I mean by an application-level memory leak is a failure to clean up such Tcl global variables as the token the [http] [package] returns from a getURL invocation. [[More explanation.]] [[Pertinent posts [http://groups-beta.google.com/group/comp.lang.tcl/msg/35e50b74fbc0d729] [http://groups-beta.google.com/group/comp.lang.tcl/msg/0606c186b5a1f850] by [tclguy] on [Tcl]'s allocator, high-water marking, ...]] ---- [EKB] 12 Mar 2006 - I have two memory-related questions: * Are compiled regular expressions released from memory? If they are, at what point does this happen? (And if not, can I call them up again without recompiling them?) ''[Lars H]: As I recall it, there are at least two places where compiled regular expressions are stored. One is in the [Tcl_Obj], and that goes away when the Tcl_Obj does or changes representation. The other is that the regular expression compiler maintains a cache of recently compiled regexps and their compiled form; I think this cache is limited to 20-or-so elements. I don't know if there are any others. [EKB] - Thanks!'' * Are [bind]ings for a window released from memory when the window is destroyed? I ask because I'm debugging a tough memory leak, and these are two prime culprits. If this is the wrong place to put such questions, please send me to the right place. ''Thanks!'' [comp.lang.tcl] might be a better place to ask. [DKF]: Bindings are indeed released, but there are things in [Tk] which are not. In particular, window names (not the full names, but just the last component of each name) and [canvas] and [text] tags (strictly, anything that is a ''Tk_Uid'') are not deleted ever in Tk 8.4. In 8.5, they are per-thread resources, which will mean that you have to dispose with the thread to get rid of them. (You could argue that this is a highly sucky situation, and I wouldn't disagree.) A workaround for this is to reuse the names of these sorts of things as much as you can. Like that, you just have high-water-mark effects instead of total-cumulative effects, meaning that virtually all programs will settle out at a certain level of usage instead of gobbling up ever more. [EKB] Thanks very much. This gives me a lot of promising things to try. ---- Also of interest: * "[memory]" * "[memory leak finding with memory trace]" * "[Why Do Programs Take Up So Much Memory ?]" * "[How to debug memory faults in Tcl and extensions]" * "[Memory introspection]" * "[Measuring memory usage]" * "[Memory Footprint Comparisons]" * "[Memory costs with Tcl]"