调用手动创建的服务实例后检测到 RemObjects 泄漏

RemObjects leaks detected after calling manually created service instance

我有以下代码创建 RemObjects 服务实例并调用 .net 服务器

class function TLabelPrintingServiceProxy.GetInstance: ILabelPrintingManager;
var
  LRoRemoteService: TRoRemoteService;
begin
  LRoRemoteService := TRoRemoteService.Create(nil);
  LRoRemoteService.Message := TROSOAPMessage.Create();
  LRoRemoteService.Channel := TROIndyHTTPChannel.Create(nil);
  LRoRemoteService.Channel.TargetUri := TROUri.Create(ILabelPrintingIntf.LabelPrintingManager_EndPointURI);

  Result := (LRoRemoteService as ILabelPrintingManager);
end;

对 .net 服务的调用是这样执行的:

  try
        Result := BinaryArray.Create;
        LLabelPrintingManager := TLabelPrintingServiceProxy.GetInstance();
        Result.Add(LLabelPrintingManager.GetVSSLabelImage(APrintJob));
    finally 
        TLabelPrintingServiceProxy.ReleaseLabelPrintingServiceProxyInstance(LLabelPrintingManager);
    end;

调用完成后,LLabelPrintingManager 接口应该由 RemObjects 自动释放,但它并没有释放所使用的对象。

我已经尝试在 ReleaseLabelPrintingServiceProxyInstance(下面的代码)上手动释放服务实例中的所有对象,但它仍然在泄漏

class procedure TLabelPrintingServiceProxy.ReleaseLabelPrintingServiceProxyInstance(aILabelPrintingManagerIntf: ILabelPrintingManager);
var
  lProxy: TRoProxy;
begin
  lProxy := TROProxy(aILabelPrintingManagerIntf);
  TROIndyHTTPChannel(lProxy.__TransportChannel).TargetUri.Free;
//  TROIndyHTTPChannel(lProxy.__TransportChannel).Free; this is generating an AV
  TRoMessage(lProxy.__Message).free;

  TRoRemoteService(aILabelPrintingManagerIntf).Free;

我错过了什么?

与 RemObjects 的人讨论后,这里是解决方案:

class function TLabelPrintingServiceProxy.GetRemoteServiceInstance: TRoRemoteService;
var
  LRoRemoteService: TRoRemoteService;
begin
  Result := TRoRemoteService.Create(nil);
  Result.Message := TROSOAPMessage.Create();
  Result.Channel := TROIndyHTTPChannel.Create(nil);
  Result.Channel.TargetUri := TROUri.Create(ILabelPrintingIntf.LabelPrintingManager_EndPointURI);
end;

通话

try
  LLabelPrintingRemoteService := TLabelPrintingServiceProxy.GetRemoteServiceInstance();
  (LLabelPrintingRemoteService as ILabelPrintingManager).PrintVSSJob(printJob);
finally
  TLabelPrintingServiceProxy.ReleaseLabelPrintingServiceProxyInstance(LLabelPrintingRemoteService);
end;

并释放对象

try
  LLabelPrintingRemoteService := TLabelPrintingServiceProxy.GetRemoteServiceInstance();
  (LLabelPrintingRemoteService as ILabelPrintingManager).PrintVSSJob(printJob);
finally
  TLabelPrintingServiceProxy.ReleaseLabelPrintingServiceProxyInstance(LLabelPrintingRemoteService);
end;