【发布时间】:2011-11-08 05:11:59
【问题描述】:
动态数组是引用计数的,因此编译器会自动释放内存。我的问题是,这种自动释放究竟是什么时候发生的?它是立即发生,还是在包含过程结束时发生?
这是一个具体的例子
procedure DoStuff;
var data:TBytes;
begin
data:=GetData; // lets say data now contains 1 Gig of data.
DoStuffWithData(data);
// I now want to free up this 1Gig of memory before continuing.
// Is this call needed, or would the memory be freed in the next line anyway?
Finalize(data);
data:=GetMoreData; // The first array now has no remaining references
DoStuffWithData(data);
end
对 Finalize() 的调用是多余的吗?
【问题讨论】:
标签: delphi