Memory leak on plain HTTPRIO

I get a memory leak when I exit my application in the THTTPRIO object I created.

I have defined my web service:

type TSimpleWebService = class protected FHTTPRIO : THTTPRIO; public constructor Create(URL : String); property HTTPRIO : THTTPRIO read FHTTPRIO; end; implementation constructor TSimpleWebService.Create(URL : String); begin FHTTPRIO := THTTPRIO.Create(nil); FHTTPRIO.URL := URL; end; 

I am testing / creating a webservice as it should (CustomerCare is my webservice interface):

 procedure TfrmMain.Button1Click(Sender: TObject); var webservice: customercare; begin webservice := GetSimpleCustomerCareService; webservice := nil; frmMain.Close; end; function TfrmMain.getSimpleCustomerCareService: CustomerCare; var webservice: TSimpleWebService; begin webservice := TSimpleWebService.Create('http://this.is.a.test'); Result := webservice.HTTPRIO as CustomerCare; end; 

When I click Button1, I do nothing but create a web service, install it again, and exit the application again. At this point (with ReportMemoryLeaksOnShutDown: = True), I get an unexpected 12 byte memory leak on TSimpleWebService.

I tried adding a Destroy destructor, but it does not seem to be called.

What am I missing?

Thanks for your input, Yang.

Oh, yes, I'm on Windows 2003 XE2. In addition to a memory leak in TSimpleWebservice, I also get a memory leak on a TDictionary object, but I don't know where this comes from. When I compile and run the same project on XE4 / Windows 7, I get only TSimpleWebservice memory leak.

+4
source share
1 answer

To answer the second question:

Oh, yes, I'm on Windows 2003 XE2. In addition to a memory leak in TSimpleWebservice, I also get a memory leak on a TDictionary object, but I don't know where this comes from. When I compile and run the same project on XE4 / Windows 7, I get only TSimpleWebservice memory leak.

There is memoryleak in wsdllookup.pas, copy this file to your project and find this code snippet

 destructor TWSDLLookup.Destroy; begin ClearWSDLLookup; inherited; end; 

Change it to:

 destructor TWSDLLookup.Destroy; begin ClearWSDLLookup; Flookup.Free; // this was missing!!!! inherited; end; 

As you know, this bug was fixed in later versions of Delphi

+4
source

Source: https://habr.com/ru/post/1494543/


All Articles