VisiBroker for Delphi 内存释放问题       Delphi中使用VisiBroker 开发CORBA应用程序,会出现Server端接口的传入参数占用内存不能正常释放的错误,具体修改方法如下:
      一、VisiBroker 4.1(Delphi 6)版本修改方法:  
      修改Delphi6\Source\Rtl\Corba40\Corba.pas 文件,找到代码段1的函数(line 687),并将其修改成代码段2。        代码段1:  
      function TCORBAObject.Execute(Operation: PChar; const Strm: 
      MarshalInBufferProxy):
      CorbaBoolean; 
      type
         TUnmarshalProc = procedure (const Input: InputStream) of object; 
      var
         M: TUnmarshalProc;
      begin
         Result := False;
         try
           TMethod(M).Code := Self.MethodAddress('_' + Operation);
           if TMethod(M).Code = nil then Exit;
           TMethod(M).Data := Self;
           M(TInputStream.Create(Strm));
         except
           Exit;
         end;
         Result := True;
      end; 
      代码段2: 
      function TCORBAObject.Execute(Operation: PChar; const Strm: 
      MarshalInBufferProxy):
      CorbaBoolean;
      type
         TUnmarshalProc = procedure (const Input: InputStream) of object;
      var
         M: TUnmarshalProc;
         inBuf : TInputStream;
      begin
         Result := False;
         try
           TMethod(M).Code := Self.MethodAddress('_' + Operation);
           if TMethod(M).Code = nil then Exit;
           TMethod(M).Data := Self;
           inBuf := TInputStream.Create(Strm);
           try
             M(inBuf);
           finally
             inBuf.free;
           end;
         except
           Exit;
         end;
         Result := True;
      end; 
       二、VisiBroker 3.3(Delphi 6 和 VisiBroker for Delphi 5)版本修改方法: 
      修改Delphi5\Source\Rtl\Corba\Corba.pas 文件,找到代码段3的函数(line 676),并将其修改成代码段4。 
      代码段3: 
      function TCORBAObject.Execute(Operation: PChar; const Strm: 
      MarshalInBufferProxy;
        Cookie: Pointer): CorbaBoolean;
      type
         TUnmarshalProc = procedure (const Input: InputStream; Cookie: Pointer) 
      of object;
      var
         M: TUnmarshalProc;
      begin
         Result := False;
         try
           TMethod(M).Code := Self.MethodAddress('_' + Operation);
           if TMethod(M).Code = nil then Exit;
           TMethod(M).Data := Self;
           M(TInputStream.Create(Strm), Cookie);
         except
           Exit;
         end;
           Result := True;
      end; 
      代码段4: 
      function TCORBAObject.Execute(Operation: PChar; const Strm: 
      MarshalInBufferProxy;
         Cookie: Pointer): CorbaBoolean;
      type
         TUnmarshalProc = procedure (const Input: InputStream; Cookie: Pointer) 
      of object;
      var
         M: TUnmarshalProc;
      begin
         Result := False;
         try 
          TMethod(M).Code := Self.MethodAddress('_' + Operation);
           if TMethod(M).Code = nil then Exit;
           TMethod(M).Data := Self;
           inBuf := TInputStream.Create(Strm);
           try
             M(inBuf, Cookie);
           finally
             inBuf.free;
           end;
         except
           Exit;
         end;
         Result := True;
      end;