Re: [問題] 沒new導致heap
我是一開始問問題的原po,我敘述一下目前我找這問題卡住的地方
主程式在這 跟一些客製化的定義都在這檔案
http://paste.plurk.com/show/213008/
主程式跟客製化函數的宣告是這檔案
http://paste.plurk.com/show/213012/
這project比較不會修改到的內部functions在這檔案
http://paste.plurk.com/show/213010/
上面那些functions的宣告在這
http://paste.plurk.com/show/213011/
我從主程式裡面的 delete sim;查(不加這行不會有堆積的問題,但會真的會
跑到記憶體不足=.=)
從~Simulation()到~Scheduler()再到~EventManager()都正常
~EventManager()裡面delete的一串物件 是new一些class繼承了class Resource
當~EventManager()每delete一個物件就會執行~Resource()
delete完最後一個RecoveryRoomLevel2_obj;後 程式會一直在~Resource()
就一直在這個解構子跑到heap的訊息出現...
在 EventManager()裡面有2個vector(ORList跟DoctorList)
放了很多new的物件進去,不知道是不是這邊寫法出問題,
不過這邊除了用vector存那些new的物件,我就不知到其他方式了
這樣問不知道會不會很亂...
感謝幫忙 m(-.-)m
※ 引述《visor (~~~~~~~~~~)》之銘言:
: 隔空抓藥一下
: 先猜 你的 class A 裡面有存在一個成員是指標變數 假設是 *ptr
: 在 class A 建構時 會去 new 一塊空間給 ptr
: 然後在 class A 的 function 裡面有做到像是下面這種動作
: class A a;
: class A b;
: b = a;
: 然後 ~A() 又去直接 delete ptr
: 才造成像這樣的錯誤
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 161.130.178.135
推
03/24 15:17, , 1F
03/24 15:17, 1F
→
03/24 15:25, , 2F
03/24 15:25, 2F
推
03/24 15:45, , 3F
03/24 15:45, 3F
推
03/24 15:51, , 4F
03/24 15:51, 4F
→
03/24 15:55, , 5F
03/24 15:55, 5F
→
03/24 16:04, , 6F
03/24 16:04, 6F
→
03/24 17:33, , 7F
03/24 17:33, 7F
→
03/24 17:40, , 8F
03/24 17:40, 8F
→
03/24 17:40, , 9F
03/24 17:40, 9F
→
03/24 17:43, , 10F
03/24 17:43, 10F
→
03/24 17:44, , 11F
03/24 17:44, 11F
→
03/24 17:45, , 12F
03/24 17:45, 12F
→
03/24 18:26, , 13F
03/24 18:26, 13F
→
03/24 19:03, , 14F
03/24 19:03, 14F
討論串 (同標題文章)