Re: [RFC] Alternate approach to keeping convenience variables

Andrew STUBBS
2006-01-04T17:48:30Z

Jim Blandy wrote:
> On 1/4/06, Andrew STUBBS <andrew.stubbs@st.com> wrote:
>
>>One point though - why is it ok to leak the memory? This seems like bad
>>practice to me - I mean, types can be arbitrarily large and, even if
>>they are typically small, the variables may be rewritten many many times
>>(particularly by scripts with loops). Are you saying that they will be
>>actually leaked or just left for some sort of garbage collection?
>
>
> No, it'll really be leaked. But the leakage only occurs when symbol
> files get unloaded from memory, so it would only affect scripts that
> load and unload symbol files in a loop. I agree it's not optimal, but
> I think the alternative is GC.
>
> Maybe we should think about that. Has anyone ever tried running GDB
> using the Boehm collector's replacements for malloc and free?
>

Perhaps you could modify copy_type_recursive such that it creates a
cleanup chain specific to the internal variable. Then call do cleanups
in set_internal_var.

Might be tricky with shared type copies though. Just a thought.