My scenario is number 1) here, so I have to be very careful with the memory use. I should then probably use
the std::copy using the inserter to copy the values into a data structure allocated using the standard
allocator. When trying to free the memory allocated by Wave when I use it as a shared library,
is it enough to delete the variable declaration of type context_type?
Regards
Andreas
> Andreas Sæbjørnsen wrote:
>
> > I need some advice regarding how I should copy the boost data
> > structures I get from 'advanced_preprocessing_hooks.h'.
> > The task at hand is to copy some of the data structures
> from Wave and
> > store it separate form the memory Wave allocates so that after the
> > Wave preprocessing step has finished all it's memory can be freed.
> >
> > Example: e.g making a copy of the
> > 'std::vector<std::list<PreprocessingInfo::token_type,boost::fa
> > st_pool_allocator<PreprocessingInfo::token_type> > >'
> > representing the arguments in the expansion of a macro in
> the function
> > 'expanding_function_like_macro'.
> >
> > Syntactically it would be gre at to be able to make a copy
> using the
> > operator=, but as far as I can see this is only possible if
> I am also
> > using the fast_pool_allocator. If I use the
> fast_pool_allocator I am
> > afraid that my copies will be put into the memory pool allocated by
> > Wave and therefore that memory cannot be safely freed. Is
> this corect?
>
> I'm not sure here. My (unverified) guess is, that the memory
> pool will be free'd only after the last item allocated from
> it got free'd. This shouldn't be a problem as long as the
> memory pool doesn't live in a shared library which gets
> unloaded prematurely.
After looking at the code and the docs again I discovered the following: the
boost::fast_pool_allocator is build on top of a thread local singleton pool.
This pool gets allocated before entering main and gets free'd after main
exits. Same should be true for shared libraries.
So yes, you're running into problems only:
1) if you have your Wave application compiled into a shared library and
2) if you use data from the allocator used by Wave in a different module
after the first shared library was explicitely unloaded from memory.
HTH
Regards Hartmut
> But anyway, doesn't using std::copy() for the embedded
> list<>'s allow to change to any adequate data structure?
>
> Regards Hartmut
>
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users