[Webkit-unassigned] [Bug 27980] Give an ability to WebKit to free statically allocated pointers before quit

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Sep 4 10:40:29 PDT 2009


https://bugs.webkit.org/show_bug.cgi?id=27980





--- Comment #32 from Yong Li <yong.li at torchmobile.com>  2009-09-04 10:40:28 PDT ---
(In reply to comment #30)
> 
> You say "sometimes it is good to free statically allocated pointers". When?

One case is that webkit is used as a dll, and the dll can be loaded and
unloaded multiple times. Those global pointers will leak in this case.

But I guess an OwnPtr or something should be good for this purpose.

The dtors will be called when the dll is unloaded. Also there is a c_exit or
_cexit in MSVC to explicitly call all dtors for global/static objects. When
constructing a global object, the compiler will add the dtor to the exit stack
with atexit. So the order of destruction is reverse order of construction. and
explicitly calling c_exit() also clears the stack, so no need to worry about
the problem of calling dtor twice. Is there a compiler that doesn't guarantee
this?

ENABLE(FREE_STATIC_PTRS) is good for not affecting people who don't want to use
it. But GlobalPtr must be freed by explicit call to deletePtr(). That's not an
easy life. Considering a coding guideline that requires using same macros for
global objects.

What are the goals?

1. construct and destruct global objects in safe order

2. ability to free all memory allocated by global pointers

3. ability to leave those global pointers as leaks.

We can just define a GlobalPtr same as OwnPtr, except there's a compile-time
switch for deleting the object in destructor or not. That would be simple but
enough for most ports I guess.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list