Artifacts Associated With Ticket 3392735fffffffff
Ticket change [8cdcdf321d] (rid 127805) by ferrieux on 2011-08-16 22:45:42:
- assignee initialized to: "msofer"
- cmimetype initialized to: "text/plain"
- comment initialized to:
With a -DPURIFY build, --enable-symbols: proc deep n { if {$n<1} exit deep [expr {$n-1}] } deep [lindex $argv 0] valgrind --leak-check=yes ./tclsh deep.tcl 10 ==2940== 27 (24 direct, 3 indirect) bytes in 1 blocks are definitely lost in loss record 33 of 50 ==2940== at 0x4005BDC: malloc (vg_replace_malloc.c:195) ==2940== by 0x402EFB8: TclpAlloc (tclAlloc.c:705) ==2940== by 0x403F188: Tcl_Alloc (tclCkalloc.c:1046) ==2940== by 0x4107C18: Tcl_NewStringObj (tclStringObj.c:340) ==2940== by 0x40E6CA4: NewNativeObj (tclMain.c:67) ==2940== by 0x40E7148: Tcl_MainEx (tclMain.c:359) ==2940== by 0x40E7977: Tcl_Main (tclMain.c:634) ==2940== by 0x8048634: main (tclAppInit.c:84) ==2940== ==2940== 216 bytes in 9 blocks are definitely lost in loss record 46 of 50 ==2940== at 0x4005BDC: malloc (vg_replace_malloc.c:195) ==2940== by 0x402EFB8: TclpAlloc (tclAlloc.c:705) ==2940== by 0x403F188: Tcl_Alloc (tclCkalloc.c:1046) ==2940== by 0x40F0286: Tcl_NewWideIntObj (tclObj.c:2909) ==2940== by 0x40ACFC1: TEBCresume (tclExecute.c:5128) ==2940== by 0x40343EA: TclNRRunCallbacks (tclBasic.c:4311) ==2940== by 0x4033EE0: Tcl_EvalObjv (tclBasic.c:4103) ==2940== by 0x4035C32: TclEvalEx (tclBasic.c:5209) ==2940== by 0x4035258: Tcl_EvalEx (tclBasic.c:4867) ==2940== by 0x40DE382: Tcl_FSEvalFileEx (tclIOUtil.c:1751) ==2940== by 0x40E72F6: Tcl_MainEx (tclMain.c:407) ==2940== by 0x40E7977: Tcl_Main (tclMain.c:634) Clearly, although full finalization has been requested, one extra obj remains for each stack level. Experimenting with extra locals in the recursive proc seems to indicate one leak per local variable. - foundin initialized to: "None"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "ferrieux"
- subsystem initialized to: "10. Objects"
- title initialized to:
Deep [exit] leaks one obj per stack level and local var.
- type initialized to: "Bug"
Ticket change [505a4f6cdb] (rid 125945) by dkf on 2011-08-17 06:03:45:
- icomment:
Why is it important to free all memory on [exit]? It just slows things down (especially with a large process) and the OS will reap all the resources. I see lots of programs in other languages which try to free everything on exit (rather than sticking to just important things) and the user experience is very negative.
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [c16750bee5] (rid 111313) by mistachkin on 2011-08-19 14:34:08:
- icomment:
It could be very important for embedding scenarios. Also, it is generally a good idea to at least try cleaning up resources on exit, since some of those resources may indirectly refer to other resources that cannot be automatically reclaimed by the operating system upon process exit.
- login: "mistachkin"
- mimetype: "text/plain"
- username: "mistachkin"
- icomment:
Ticket change [997e9440aa] (rid 110807) by ferrieux on 2011-08-19 19:19:39:
- icomment:
Donal, again this special setup uses a forced-finalization-on-exit as a means, not an end :) It is simply the only way to see leaks stand out. Once detected, many leaks prove to go beyond the exit sequence and can also be iterated in mid-life. Moreover, even teardown-time leaks can matter if they occur at the end of a thread (which is a repeatable condition). It is precisely the case here. Now the forced finalization doesn 't occur in production builds; only in -DPURIFY (see http://wiki.tcl.tk/28634 ) or when env var TCL_FINALIZE_ON_EXIT is set. So don't fear any slowdown in normal use.
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [2b507f6a0e] (rid 118720) by dkf on 2011-08-19 19:39:42:
- icomment:
Joe, when there are resources that must be cleaned up on exit, a specific exit handler should be registered to deal with them; there's a separate API for that. That API should not be (ab)used for doing memory cleanup though. (I differentiate with finalizing an interpreter; in that case there's a reasonable need to try to cleanse memory thoroughly. But it's not [exit].) Alex, that's why it is important to say what you mean and not a proxy for it. The [exit] command should not be doing memory cleanup because of the issues I raised (other critical cleanup is the proper domain of an exit handler) but that doesn't mean that there is no need for testing finalization. (Suggestion: try ripping the rug out from under a sub-interp's feet using the master interpreter.)
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [8669fe1a48] (rid 131505) by dgp on 2011-09-24 02:55:14:
- assignee changed to: "dgp"
- closedate changed to: "2011-09-23T19:55:14"
- closer changed to: "dgp"
- icomment:
allow_comments - 1 The key here is the use of [exit] in the script. Change "exit" to "return" and all traces of leakage go away. [exit] causes leaks. That's ticket 3400944.
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Duplicate"
- status changed to: "Closed"
- username: "dgp"