>> >Hi,
>>
>> >Fractal wrote:
>> >> Hi all
>> >> rtree is a great library?I used it in my project, everything is ok except random crash after I updated program bin file.
>> >> i dig into the source code of rtree,found the crash was caused by using virtual function at node class. I also found that there is a static version of node class. is this a to be implement feature, or I'm using rtree in the wrong way?
>> here is the minimal example which exhibit the problem, you run the program the first time, is ok, but the second time, it crashed in insert method,
>> i'm using vs2012, and the os is win7, in linux version, i observed that only i recompile my program and restart it, will it crash.
>Yes, indeed the polymorphic nodes are the cause of this crash. So from
>now on Boost.Variant-based nodes are used by default in the rtree:
>https://github.com/boostorg/geometry/commit/3474244d0a91d63752cd8a7b683fd013da030750
>The side effects (according to the
>index/example/benchmark_experimental.cpp) are:
>- slower inserts on MSVC
>- faster inserts on GCC
>- smaller memory consumption
>I plan to rewrite and optimize the nodes dispatching in the future when
>I have more free time, for now the above should do the job.
>If you can use the development branch of the library, just get the
>latest version of Boost or Boost.Geometry from GitHub.
>If you need a workaround for a previously released version of Boost you
>may do exactly the same changes I've made directly in the library or
>write something like this:
>#include <boost/geometry.hpp>
>#include <boost/geometry/index/rtree.hpp>
>struct my_linear_tag {};
>namespace boost { namespace geometry { namespace index { namespace
>detail { namespace rtree {
>template <>
>struct options_type<my_linear_tag>
>{
> typedef options<
> index::linear<32, 8>,
> insert_default_tag,
> choose_by_content_diff_tag,
> split_default_tag,
> linear_tag,
> node_s_mem_static_tag
> > type;
>};
>}}}}}// namespace boost::geometry::index::detail::rtree
>// ...
>typedef bgi::rtree<rtree_value_type, my_linear_tag, indexable_t,
>equal_to_t, rtree_allocator_t> rtree_t;
>Let me know if one of the solutions works for you.
that's great! Adam, i tried all the solutions you mentioned above,
the my_linear_tag method failed to compile the insert method,
compiler complains:
D:\boost\boost_1_54_0\boost/geometry/index/rtree.hpp(1048): error C2664: ˇ°boost::geometry::index::detail::rtree::visitors::insert<Element,Value,Options,Translator,Box,Allocators,InsertTag>::insert(boost::interprocess::offset_ptr<PointedType,DifferenceType,OffsetType,OffsetAlignment> &,size_t &,const Value &,const boost::geometry::index::linear<MaxElements,MinElements> &,const Translator &,Allocators &,size_t)ˇ±: cannot convert parameter 5 from ˇ°params_tˇ± to ˇ°const boost::geometry::index::linear<MaxElements,MinElements> &ˇ±
then i modified the boost/geometry/index/detail/rtree/options.hpp according to github, and it worked perfectly!
thanks Adam.