A bit of history - there is some_lib.dll library (implemented in visual studio), using regasm I register and create a type library, which I later import into the delphi project with the creation of wrappers. In Delphi, the following code:
procedure DoSomething(); var _id: Integer; _class: TClass; // TClass - класс из файла-обертки библиотеки типов _obj: OleVariant; // ссылка на объект, созданный после вызова одной из функций dll begin try _id := 123; _class := TClass.Create(nil); _obj := _class.GetObject(123); // создаем объект, возвращаем ссылку _class.TreatObject(_obj); // передаем ссылку в другой метод, обрабатываем объект _class.TreatObjectAgain(_obj); // передаем ссылку в третий метод, опять что-то с ним делаем finnaly _class.Free; // _obj ??? end; end; The question is - how to properly free the memory occupied by the _obj? As far as I understand, the object will remain in memory after the function completes.
AddRef/Release) automatically go and when the normal implementation of the original dll comes out ofDoSomethingit will be destroyed, because . the reference count to it will reach 0. In general, FastMM and analogs are in your hands :) - kami