| Paul Pluzhnikov 2005-11-24, 5:54 pm |
| "Maxim Yegorushkin" <maxim.yegorushkin@gmail.com> writes:
> libstdc++ allocator does caching. Will there be any problems when
> memory allocated and freed by allocators in different DSOs?
Not usually: the allocator gets a large "chunk" from malloc(),
slices it into object-sized pieces, and gives them to the
application.
If the app then "gives it back", the slice goes onto the allocator's
free-list.
It doesn't matter which instance of the allocator gets the slice.
The only trouble with mismatch can come as a memory leak, if the
allocator which has non-empty freelist is in a DSO which gets
unloaded (via dlclose()). But the exact same trouble would come
even without mismatch: load a DSO with libstdc++ statically bound
into it, construct some objects, unload the DSO -- the exact same
leak will result (assuming the objects aren't destructed in the
DSO finalizer).
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
|