动态数组是引用计数,所以内存被编译器自动释放.我的问题是,何时发生这种自动释放?它会立即发生,还是在包含程序结束时发生?
这是一个具体的例子
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()是多余的吗?