[問題] Return memory to OS from big std::map

看板C_and_CPP作者 (拒看低質媒體)時間10年前 (2014/01/10 22:49), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) Linux G++ 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) No 問題(Question): 如何設計allocator讓刪除std::map之後能把消耗的記憶體返回給OS 補充說明(Supplement): 我正在撰寫多Process和MPI的C++ extension of R 來處理大量資料。 其中在data cleaning的時候,需要使用 std::map<std::string, std::map<std::string, int> > 建立Index來加速random access。 但是當整理完畢之後,我刪除std::map之後卻發現記憶體並沒有歸還到OS, 所以後續R 要調用記憶體的時候就不足了。 後來我注意到這篇文章: http://stackoverflow.com/questions/2629018/how-do-i-force-my-stdmap-to-deallocate-memory-used (縮網址:http://0rz.tw/VxcBo) 看起來這是預設的memory allocator的行為。 我想請問,除了下面有人提到用boost的pool library來自製memory allocator之外, 還有沒有什麼其他建議呢?(例如改用其他資料結構或是第三方library) 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 1.34.138.85 ※ 編輯: Wush978 來自: 1.34.138.85 (01/10 22:52) ※ 編輯: Wush978 來自: 1.34.138.85 (01/10 22:52)
文章代碼(AID): #1Iq0XYK5 (C_and_CPP)
文章代碼(AID): #1Iq0XYK5 (C_and_CPP)