Overview
| Artifact ID: | 41c40a341bc403201e4839db48bd63bba0186f6cf72576912a16121d9216b9e0 |
|---|---|
| Ticket: | e8b18d7b1fbe160a09d9d7dad382a3d150b41c87
EncodingConvert{to,from}ObjCmd do not free Tcl_Encoding on error paths |
| User & Date: | apnadkarni on 2025-06-18 14:08:38 |
Changes
- icomment:
Appreciate the warning but I am indeed aware of the loading and caching mechanism for encodings. However, note that * The success case does in fact call `Tcl_FreeEncoding` but the error case does not. This inconsistency does not make sense if the goal is to keep encodings in memory. * The functions in question actually use `Tcl_GetEncodingFromObj` which in effect adds an extra reference count for exactly that reason. Even with a `Tcl_FreeEncoding` it will stay in memory until the caching `Tcl_Obj` is freed or shimmered. So for instance when the encoding name is within a proc, it will effectively keep in the encoding in memory as long as the proc's bytecode exists. * As an aside, there is a non-trivial amount of code that deals with caching of encoding with a shared table and mutex access. So I presume at some point it was thought to be important to discard encoding tables. I am not sure what was considered a lot of memory three decades ago is true anymore and at some point it might be worth looking at never releasing loaded encodings, thereby both simplifying the code and more efficient encoding operations by avoiding the locks and cache flushes.
- login: "apnadkarni"
- mimetype: "text/x-markdown"