Re: [PATCH] [RFC] Add g_*_deinit() API



On Thu, Sep 30, 2010 at 11:53 PM, Ole André Vadla Ravnås
<oleavr gmail com> wrote:
> On Thu, Sep 30, 2010 at 11:24 PM, David Zeuthen <zeuthen gmail com> wrote:
>> This bug
>>
>>  https://bugzilla.gnome.org/show_bug.cgi?id=627423
>>
>> is an attempt at making GLib valgrind friendly. (snip)
>
> Sorry, I completely missed out on that bug. I really like your
> approach, it's much cleaner than the one I went ahead with. I'll put
> my patch aside and start working from yours. Awesome stuff! :-)

Although I really liked it at first, after sleeping on it I woke up
feeling a bit uneasy about this "free-list" approach, because of a few
things that came to me:
1) It will lower the mental threshold for having global state where
this is a bad architectural choice, but laziness makes it a very
tempting thing to do.
2) Also lowers the threshold for premature optimizations using global state.
3) We cannot use it for cleaning up GSlice or GThread because the
"free-list" implementation depends on these. So some kind of explicit
deinit would be needed there.
4) Ordering might be a bit tricky. If two modules allocate resources
lazily, and one depends on the other, the first might clean up right
before it is used by the second one as part of its cleanup. This is
probably mitigated by not allowing arbitrary callbacks on shutdown,
but simply g_free/g_slice_free.

My biggest concerns are 1) and 2). What do you guys think?

Ole André


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]