A memory leak in the VCL BUG

zhaozj2021-02-11  161

In Valedit.PAS, the TVALUELISTSTRINGS class does not implement the virtual Destroy method, which implements the virtual CLEAR method, but its parent class TSTRINGLIST does not release the resource by calling clear (), so Tvalueliststrings Assign member ItemProps The memory is lost.

So if a TVALUELISTEDITOR control is added in the Form, its ItemProperty member is used in the code (because it is delayed allocation, only the memory is allocated when using it), you need to explicit in the form.destroy () method. Call the clear () method, as follows:

MyForm.Destroy () {... myvaluelisteditor-> strings-> clear (); ...}

This is found in the VCL SOURCE of C Builder 6, which is estimated that this bug should also be in Delphi 6.

转载请注明原文地址:https://www.9cbs.com/read-6017.html

New Post(0)