作者ric2k1 (Ric)
看板EE_DSnP
標題[64-bit 使用者請注意] Re: [BUG]找不出來
時間Tue May 6 23:40:25 2008
※ 引述《lec1987 (述)》之銘言:
: 以下是我使用mtn的時候所出現的狀況
: mtest> mtn 100
: Calling alloc...(12)
: Calling MemMgr::getMem...(12)
: memTest: memMgr.h:304: size_t MemMgr<T>::getRecycleIdx(size_t) const [with T
: = MemTestObj]: Assertion `t >= ((sizeof(T) + (sizeof(size_t) - 1)) /
: sizeof(size_t) * sizeof(size_t))' failed.
: Abort
: 可是我304行是getRecycleIdx的程式
: size_t getRecycleIdx(size_t t) const {
: assert(t >= S);
: return (t - SIZE_T) / S;
: }
: 在一進入以後
: t= 12當然掛掉....
: 我在cad應該是64位元S應該是等於16吧
: t<S掛...........
: 請問一下可能會是哪裡的問題呢??謝!
In 64-bit machine, memory data are 8-byte aligned. That is, sizeof(size_t) = 8.
Since sizeof(T) = 12, therefore, S = (12 + 7)/8 * 8 = 16 and all the memory
allocation should be multiples of 16 (S).
..==> In the first TODO of getMem, please make sure your request memory is
multiple of S.
..==> Note that 32-bit machine users happen to get rid of this problem because
12 is a multiple of 4 (i.e. sizeof(size_t)).
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.121.134.232
※ 編輯: ric2k1 來自: 59.121.134.232 (05/06 23:41)
1F:推 lec1987:謝謝老師..所以問題是出在memBlock的getMem嗎? 05/07 00:09
2F:→ ric2k1:嗯, 請想想 & 試試看! 05/07 00:27