Q
qqjm
Unregistered / Unconfirmed
GUEST, unregistred user!
写了一个做为缓冲的类,当设置缓冲的数量超过2800条时,在释放对象时程序会弹出“Access violation at address 0040510c in module 'project1.exe'. write of address 0103FFFC”的错误,执行第二次才能成功,十分不解。是Delphi的内存管理问题还是我设计的问题?
TSmsMsgItem=record
....
_SmsLists:Array of TSmsMsgItem; //sizeof(TSmsMsgItem)=352
.....
constructor TSmsMsgList.Create(iMinCount: integer);
begin
getMem(self._SmsLists ,iMinCount*sizeof(TSmsMsgItem));
end;
destructor TSmsMsgList.Destroy;
begin
FreeMem(self._SmsLists);
inherited ; //到这里出错,但是如果少于2900则没问题!
end;
TSmsMsgItem=record
....
_SmsLists:Array of TSmsMsgItem; //sizeof(TSmsMsgItem)=352
.....
constructor TSmsMsgList.Create(iMinCount: integer);
begin
getMem(self._SmsLists ,iMinCount*sizeof(TSmsMsgItem));
end;
destructor TSmsMsgList.Destroy;
begin
FreeMem(self._SmsLists);
inherited ; //到这里出错,但是如果少于2900则没问题!
end;