作者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