A gdzie masz tam cos napisane o resourcach? Rzucilem na szybko okiem i nie ma nic o automagicznym zwalnianiu
EDIT: Mea culpa. Jednak jest cos o "Release" i "Destroy", ale bez dedykowanego rozdzialu
The effect is not limited only to visibility. A managed variable, like an interface reference or a record, will be properly cleaned up at the end of the block, rather than at the end of the procedure or method:
Kopiuj
procedure Test99;
begin
// some code
if (something) then
begin
var Intf: IInterface = GetInterface; // Intf.AddRef
var MRec: TManagedRecord = GetMRecValue; // MRec.Create + MRec.Assign
UseIntf(Intf);
UseMRec(MRec);
end; // Intf.Release and MRec.Destroy are implicitly called at end of scope
// more code
end; // no additional cleanup
Zakladam, ze kluczowe sformulowanie jest tutaj:
rather than at the end of the procedure or method
Czyli jesli end procedure nie zwalnia danego obiektu, to ta konstrukcja tez nie