Unused interface reference is not destroyed

后端 未结 2 1220
轻奢々
轻奢々 2021-02-09 06:47

i had another bug in my app caused by careless usage of Delphi interfaces. When i pass an interface to a procedure which ignores that argument, the instance is never freed. See

相关标签:
2条回答
  • 2021-02-09 07:08

    It is a different manifestation of the bugs here.
    I will add this to the QC report.

    This does not reproduce in Delphi XE update 1 any more.

    --jeroen

    0 讨论(0)
  • 2021-02-09 07:20

    Add a guid to you ITest declaration

    ITest = interface
    ['{DB6637F9-FAD3-4765-9EC1-0A374AAC7469}']
        procedure Test;
    end;
    

    Change the loop to this

    for x in list do
        x.UseTestOrNot(Tester.Create as ITest);
    

    The GUID is neccesary to be able to use as

    Test.Create as ITest makes the compiler to add the release where the created object goes out of scope.

    0 讨论(0)
提交回复
热议问题