I'm trying to remove exit time destructors from chrome. A exit time
destructor is a destructor that runs on program shutdown. They are
used by global objects, and by function-local statics:
// Requires an exit time destructor,
// and probably also requires a static initializer:
MyClassWithDestructor g_my_object;
void f() {
// Requires an exit time destructor.
static MyClassWithDestructor s_my_local_object;
}
In almost all cases, object destructors don't do things that are
necessary at program shutdown and mostly slow down shutdown (in part
because they might require swapping in a piece of code that was
swapped out, just for running a destructor that nobody really cares
about). I think it's worth getting rid of them, and I started working
on this. As a side effect, I'm also removing static initializers (in
the "global objects" case).
clang has a warning, -Wexit-time-destructors, that detects these
destructors and warns about them. I turned that warning on for
content/ and ui/, and I'll try to turn it on for all other targets as
well as I clean them up. The Apple WebKit/mac port has been building
with this flag set for a few months already.
If you run into that warning,
http://code.google.com/p/chromium/issues/detail?id=101600#c15 has
examples of how to get rid of exit time destructors.
If you disagree with removing exit time destructors, please speak up now :-)
Thanks,
Nico
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
I think there are people working on this (http://crbug.com/97701), but
it's a bit out. For local statics, putting in CR_DEFINE_LOCAL_STATIC
is just as easy and will have the same effect now and after that work
is done, so there's little harm in it. Global statics need to be
prevented either way because they also require static initialization.
Hence, I think there isn't much harm in removing exit time destructors
anyway.
Nico
I believe it'll continue to work for stuff that's using an
AtExitManager. LazyInstances with LeakyLazyInstance aren't. Are you
worried about anything specific?
Nico
http://code.google.com/p/chromium/issues/detail?id=43782Yes, memory bots are a concern.
If the memory is still reachable from static objects, it's not counted as a leak