2011-12-15 9 views
0

私のプログラムは更新を含むメッセージを処理します。各メッセージは複数の更新を持つことができます。 私はブーストunorderedマップを使用して、処理が行われるupdate identiferおよびcorrespondingpingオブジェクトを格納しています。ブースト無秩序マップを使用している間のアロケータ例外

私はこのようなことをします。

unorderedUpdateMap[updateID] = processObject; 

通常、プログラムは正常に動作します。しかし、負荷が重い状況(更新が多い場合)は、リストがおそらく大きな値になり、コアダンプに続いてプロセスがクラッシュします。

(gdb) bt 
#0 0x00007fcbf562b678 in (anonymous namespace)::cpp_alloc(unsigned long, bool)() from /opt/gts/3pp/usr/lib64/libtcmalloc_minimal.so.0 
#1 0x00007fcbf5635218 in tc_new() from /opt/gts/3pp/usr/lib64/libtcmalloc_minimal.so.0 
#2 0x00007fcbeb7bee14 in __gnu_cxx::new_allocator<boost::unordered_detail::hash_node<std::allocator<std::pair<long const, mds::InstrumentData*> >, boost::unordered_detail::ungrouped> >::allocate 
    (this=0x472d3b0, __n=1) at /usr/lib/gcc/x86_64-redhat-linux6E/4.4.0/../../../../include/c++/4.4.0/ext/new_allocator.h:89 
#3 0x00007fcbeb7bd191 in boost::unordered_detail::hash_node_constructor<std::allocator<std::pair<long const, mds::InstrumentData*> >, boost::unordered_detail::ungrouped>::construct_preamble (
    this=0x53c67f90) 
    at /usr/include/boost/unordered/detail/util.hpp:319 
#4 0x00007fcbeb7bb2d9 in boost::unordered_detail::hash_node_constructor<std::allocator<std::pair<long const, mds::InstrumentData*> >, boost::unordered_detail::ungrouped>::construct_pair<long, mds::InstrumentData*> (this=0x53c67f90, [email protected]) 
    at /usr/include/boost/unordered/detail/util.hpp:267 
#5 0x00007fcbeb7b9497 in boost::unordered_detail::hash_unique_table<boost::unordered_detail::map<long, boost::hash<long>, std::equal_to<long>, std::allocator<std::pair<long const, mds::InstrumentData*> > > >::operator[] (this=0x472d3a0, [email protected]) 
    at /usr/include/boost/unordered/detail/unique.hpp:203 
#6 0x00007fcbeb7b787f in boost::unordered_map<long, ProcessObject*, boost::hash<long>, std::equal_to<long>, std::allocator<std::pair<long const, ProcessObject*> > >::operator[] (
    this=0x472d3a0, [email protected]) 

(スタックトレースで提案されているように)私はさらにアロケータソースに行けば

// NB: __n is permitted to be 0. The C++ standard says nothing 
    // about what the return value is when __n == 0. 
    pointer 
    allocate(size_type __n, const void* = 0) 
    { 
    if (__builtin_expect(__n > this->max_size(), false)) 
     std::__throw_bad_alloc(); 
    return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp))); (The line which was resonpsible for crash) 
    } 

は、私は、マップ内の任意のカスタムアロケータを使用しないでください。しかし、私たちのプログラムはtcmallocパッケージとリンクしています。 これはメモリの問題ですか?このようなシナリオに備えるために事前配分を行う必要がありますか?

+0

を使用していますを示すメモリのプロファイルを表示する

valgrind --tool=massif ./mytestprogram ms_print massif* | less -SR 

を使用することができます – Mansuro

+0

「私はカスタムアロケータを使用していません」と「/opt/gts/3pp/usr/lib64/libtcmalloc_minimal.so.0」はうまく収まりません... – PlasmaHH

+0

@PlasmaHH:libtcmallocはアロケータを提供していません。それは単にmalloc/freeを置き換えます。 – sehe

答えて

0

単純にメモリ不足のようです。

メモリ割り当てが失敗したようです。これは、不十分なメモリまたはメモリのリークが原因である可能性があります。

私はこれらの情報を取得するために

valgrind ./mytestprogram 

を示唆しています。

ます。また、メモリーがどこに割り当てられます正確に何を、なぜ、どのような、あなたが持っているより多くのチャンスを明確にご質問がある最も大きい部分

関連する問題