作者mmm321 (家家)
看板C_and_CPP
標題[問題] map爆記憶體問題
時間Thu Apr 25 13:35:29 2013
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
Linux
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
Boost
問題(Question):
將兩個5.65G的檔案分別塞到兩個map,兩個檔案內分別有幾十萬筆筆資料,
我要保留兩檔案具有相同Key的Value,所以目前是用map 搭配find來完成。
但似乎檔案真的太大了,執行時會出現錯誤。
用小的test case有測過程式,結果是我要的沒錯
想請問一下我這個問題有沒有辦法解決
餵入的資料(Input):
兩個5.65G的檔案
預期的正確結果(Expected Output):
No error!
錯誤結果(Wrong Output):
terminate called after throwing an instance of 'std::bad_alloc'
what(): St9bad_alloc
Aborted
程式碼(Code):(請善用置底文網頁, 記得排版)
http://ideone.com/f6ztxU
補充說明(Supplement):
麻煩大家了 :)
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.239.247
→ azureblaze:32bit還64bit? 32bit單一程式記憶體通常只能用到2G 04/25 13:38
→ mmm321:不好意思,那請問64的可以到多大呢? 機器是32的沒錯 :( 04/25 13:39
→ hilorrk:做 join 感覺不需要全部存到記憶體 04/25 14:45
→ azureblaze:64可以到8TB 04/25 15:55
→ azureblaze:可是我覺得你應該想不需要一次全部讀進來的演算法 04/25 15:55
推 ZanFu5566:32BIT 4G 04/25 17:03
→ olozil:linux可以射單一process可用內存上限, 不過還是受限32bit 04/25 17:56
→ mmm321:謝謝大家,我改用只存一個map,且移到64bit的機器解決了 :) 04/25 17:58
→ tinlans:有沒有這麼誇張,資料結構很複雜嗎?你乾脆用 sqlite 吧。 04/27 16:55