Fórum Memory Leak Web Services Delphi Prism #400936
12/05/2011
0
um web service feito em delphi prism pelo delphi xe , esta reportando Memory leak ao fechar a aplicação
como pode ser visto a partir da imagem abaixo
Alguem fez o exemplo e teve resultados diferentes ??????
Obs) não esquecer de colocar ReportMemoryLeaksOnShutdown := true;
Marco Salles
Curtir tópico
+ 0Posts
12/05/2011
Vitor Rubio
Talvez alguma diferença nas opções do WSDLimporter tenha causado isso.
Você está usando algum variant?
Estou usando RAD Studio XE e Delphi Prism instalado no Visual Studio 2008 e não tive esse problema. Estou com os projetos abertos agora. Vou ver se consigo extrair um relatório de leak mais detalhado, pois o ReportMemoryLeaksOnShutdown só mostra a mensagem se tem ou não memory leak e o que está na memória. Quando agente usava o fastMM o relatório salvo em txt era mais detalhado.
Gostei + 0
12/05/2011
Marco Salles
Olá Marcos, boa tarde, você pode disponibilizar o código completo, inclusive o Service.pas gerado automaticamente pelo wsdl importer?
boa tarde vitor. Primeiro lugar agradecer a sua sempre cordial atençã a todos aqueles que lhe socorrem
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://localhost:39759/PrismWebService/Service.asmx?WSDL
// >Import : http://localhost:39759/PrismWebService/Service.asmx?WSDL>0
// Encoding : utf-8
// Version : 1.0
// (12/05/2011 10:54:22 - - $Rev: 34800 $)
// ************************************************************************ //
unit Service;
interface
uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;
const
IS_OPTN = $0001;
IS_REF = $0080;
type
// ************************************************************************ //
// The following types, referred to in the WSDL document are not being represented
// in this file. They are either aliases[@] of other types represented or were referred
// to but never[!] declared in the document. The types from the latter category
// typically map to predefined/known XML or Embarcadero types; however, they could also
// indicate incorrect WSDL documents that failed to declare or import a schema type.
// ************************************************************************ //
// !:string - "http://www.w3.org/2001/XMLSchema"[Gbl]
// !:int - "http://www.w3.org/2001/XMLSchema"[Gbl]
contato = class; { "http://tempuri.org/"[GblCplx] }
// ************************************************************************ //
// XML : contato, global, <complexType>
// Namespace : http://tempuri.org/
// ************************************************************************ //
contato = class(TRemotable)
private
FNome: string;
FNome_Specified: boolean;
FEmail: string;
FEmail_Specified: boolean;
FTelefone: string;
FTelefone_Specified: boolean;
procedure SetNome(Index: Integer; const Astring: string);
function Nome_Specified(Index: Integer): boolean;
procedure SetEmail(Index: Integer; const Astring: string);
function Email_Specified(Index: Integer): boolean;
procedure SetTelefone(Index: Integer; const Astring: string);
function Telefone_Specified(Index: Integer): boolean;
published
property Nome: string Index (IS_OPTN) read FNome write SetNome stored Nome_Specified;
property Email: string Index (IS_OPTN) read FEmail write SetEmail stored Email_Specified;
property Telefone: string Index (IS_OPTN) read FTelefone write SetTelefone stored Telefone_Specified;
end;
// ************************************************************************ //
// Namespace : http://tempuri.org/
// soapAction: http://tempuri.org/%operationName%
// transport : http://schemas.xmlsoap.org/soap/http
// style : document
// use : literal
// binding : ServiceSoap12
// service : Service
// port : ServiceSoap12
// URL : http://localhost:39759/PrismWebService/Service.asmx
// ************************************************************************ //
ServiceSoap = interface(IInvokable)
['{89A44D6C-629E-14C5-0478-33BE4DB9ED3E}']
function HelloWorld: string; stdcall;
function Soma(const x: Integer; const y: Integer): Integer; stdcall;
function EchoString(const s: string): string; stdcall;
function CriaContato(const nome: string; const email: string; const telefone: string): contato; stdcall;
procedure EchoContato(const c: contato); stdcall;
end;
function GetServiceSoap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): ServiceSoap;
implementation
uses SysUtils , dialogs;
function GetServiceSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): ServiceSoap;
const
defWSDL = 'http://localhost:39759/PrismWebService/Service.asmx?WSDL';
defURL = 'http://localhost:39759/PrismWebService/Service.asmx';
defSvc = 'Service';
defPrt = 'ServiceSoap12';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
if HTTPRIO = nil then
RIO := THTTPRIO.Create(nil)
else
RIO := HTTPRIO;
try
Result := (RIO as ServiceSoap);
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;
end;
procedure contato.SetNome(Index: Integer; const Astring: string);
begin
FNome := Astring;
FNome_Specified := True;
end;
function contato.Nome_Specified(Index: Integer): boolean;
begin
Result := FNome_Specified;
end;
procedure contato.SetEmail(Index: Integer; const Astring: string);
begin
FEmail := Astring;
FEmail_Specified := True;
end;
function contato.Email_Specified(Index: Integer): boolean;
begin
Result := FEmail_Specified;
end;
procedure contato.SetTelefone(Index: Integer; const Astring: string);
begin
FTelefone := Astring;
FTelefone_Specified := True;
end;
function contato.Telefone_Specified(Index: Integer): boolean;
begin
Result := FTelefone_Specified;
end;
initialization
{ ServiceSoap }
InvRegistry.RegisterInterface(TypeInfo(ServiceSoap), 'http://tempuri.org/', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(ServiceSoap), 'http://tempuri.org/%operationName%');
InvRegistry.RegisterInvokeOptions(TypeInfo(ServiceSoap), ioDocument);
InvRegistry.RegisterInvokeOptions(TypeInfo(ServiceSoap), ioSOAP12);
{ ServiceSoap.HelloWorld }
InvRegistry.RegisterMethodInfo(TypeInfo(ServiceSoap), 'HelloWorld', '',
'[ReturnName="HelloWorldResult"]', IS_OPTN);
{ ServiceSoap.Soma }
InvRegistry.RegisterMethodInfo(TypeInfo(ServiceSoap), 'Soma', '',
'[ReturnName="SomaResult"]');
{ ServiceSoap.EchoString }
InvRegistry.RegisterMethodInfo(TypeInfo(ServiceSoap), 'EchoString', '',
'[ReturnName="EchoStringResult"]', IS_OPTN);
{ ServiceSoap.CriaContato }
InvRegistry.RegisterMethodInfo(TypeInfo(ServiceSoap), 'CriaContato', '',
'[ReturnName="CriaContatoResult"]');
RemClassRegistry.RegisterXSClass(contato, 'http://tempuri.org/', 'contato');
end.
Vitor este memory leak a quem lhe reporto ocorre mesmo se comentar todas as linhas deixando apenas a instrução
serv := GetServiceSoap();
obrogado
Gostei + 0
12/05/2011
Vitor Rubio
Deixe-me ver o código que você usa para chamar.
O estranho é que serv é uma interface. Deveria ser destruida automaticamente.
O meu services.pas está um pouco diferente. Veja:
// ************************************************************************ //// The types declared in this file were generated from data read from the// WSDL File described below:// WSDL : http://localhost:1476/PrismWebService/Service.asmx?WSDL// >Import : http://localhost:1476/PrismWebService/Service.asmx?WSDL>0// Encoding : utf-8// Version : 1.0// (21/2/2011 14:56:19 - - $Rev: 28374 $)// ************************************************************************ //
unit Service;
interface
uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;
const IS_OPTN = $0001; IS_REF = $0080;
type
// ************************************************************************ // // The following types, referred to in the WSDL document are not being represented // in this file. They are either aliases[@] of other types represented or were referred // to but never[!] declared in the document. The types from the latter category // typically map to predefined/known XML or Embarcadero types; however, they could also // indicate incorrect WSDL documents that failed to declare or import a schema type. // ************************************************************************ // // !:string - "http://www.w3.org/2001/XMLSchema"[Gbl] // !:int - "http://www.w3.org/2001/XMLSchema"[Gbl]
contato = class; { "http://tempuri.org/"[GblCplx] }
// ************************************************************************ // // XML : contato, global, <complexType> // Namespace : http://tempuri.org/ // ************************************************************************ // contato = class(TRemotable) private FNome: string; FNome_Specified: boolean; FEmail: string; FEmail_Specified: boolean; FTelefone: string; FTelefone_Specified: boolean; procedure SetNome(Index: Integer; const Astring: string); function Nome_Specified(Index: Integer): boolean; procedure SetEmail(Index: Integer; const Astring: string); function Email_Specified(Index: Integer): boolean; procedure SetTelefone(Index: Integer; const Astring: string); function Telefone_Specified(Index: Integer): boolean; published property Nome: string Index (IS_OPTN) read FNome write SetNome stored Nome_Specified; property Email: string Index (IS_OPTN) read FEmail write SetEmail stored Email_Specified; property Telefone: string Index (IS_OPTN) read FTelefone write SetTelefone stored Telefone_Specified; end;
// ************************************************************************ // // Namespace : http://tempuri.org/ // soapAction: http://tempuri.org/%operationName% // transport : http://schemas.xmlsoap.org/soap/http // style : document // binding : ServiceSoap12 // service : Service // port : ServiceSoap12 // URL : http://localhost:1476/PrismWebService/Service.asmx // ************************************************************************ // ServiceSoap = interface(IInvokable) ['{89A44D6C-629E-14C5-0478-33BE4DB9ED3E}'] function HelloWorld: string; stdcall; function Soma(const x: Integer; const y: Integer): Integer; stdcall; function EchoString(const s: string): string; stdcall; function CriaContato(const nome: string; const email: string; const telefone: string): contato; stdcall; procedure EchoContato(const c: contato); stdcall; end;
function GetServiceSoap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): ServiceSoap;
implementation uses SysUtils;
function GetServiceSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): ServiceSoap;const defWSDL = 'http://localhost:2743/Service.asmx?WSDL'; defURL = 'http://localhost:2743/Service.asmx'; defSvc = 'Service'; defPrt = 'ServiceSoap12';var RIO: THTTPRIO;begin Result := nil; if (Addr = '') then begin if UseWSDL then Addr := defWSDL else Addr := defURL; end; if HTTPRIO = nil then RIO := THTTPRIO.Create(nil) else RIO := HTTPRIO; try Result := (RIO as ServiceSoap); if UseWSDL then begin RIO.WSDLLocation := Addr; RIO.Service := defSvc; RIO.Port := defPrt; end else RIO.URL := Addr; finally if (Result = nil) and (HTTPRIO = nil) then RIO.Free; end;end;
procedure contato.SetNome(Index: Integer; const Astring: string);begin FNome := Astring; FNome_Specified := True;end;
function contato.Nome_Specified(Index: Integer): boolean;begin Result := FNome_Specified;end;
procedure contato.SetEmail(Index: Integer; const Astring: string);begin FEmail := Astring; FEmail_Specified := True;end;
function contato.Email_Specified(Index: Integer): boolean;begin Result := FEmail_Specified;end;
procedure contato.SetTelefone(Index: Integer; const Astring: string);begin FTelefone := Astring; FTelefone_Specified := True;end;
function contato.Telefone_Specified(Index: Integer): boolean;begin Result := FTelefone_Specified;end;
initialization InvRegistry.RegisterInterface(TypeInfo(ServiceSoap), 'http://tempuri.org/', 'utf-8'); InvRegistry.RegisterDefaultSOAPAction(TypeInfo(ServiceSoap), 'http://tempuri.org/%operationName%'); InvRegistry.RegisterInvokeOptions(TypeInfo(ServiceSoap), ioDocument); InvRegistry.RegisterInvokeOptions(TypeInfo(ServiceSoap), ioSOAP12); InvRegistry.RegisterMethodInfo(TypeInfo(ServiceSoap), 'HelloWorld', '', '', IS_OPTN); InvRegistry.RegisterParamInfo(TypeInfo(ServiceSoap), 'HelloWorld', 'HelloWorldResult', '', '', IS_OPTN); InvRegistry.RegisterMethodInfo(TypeInfo(ServiceSoap), 'EchoString', '', '', IS_OPTN); InvRegistry.RegisterParamInfo(TypeInfo(ServiceSoap), 'EchoString', 's', '', '', IS_OPTN); InvRegistry.RegisterParamInfo(TypeInfo(ServiceSoap), 'EchoString', 'EchoStringResult', '', '', IS_OPTN); InvRegistry.RegisterParamInfo(TypeInfo(ServiceSoap), 'CriaContato', 'nome', '', '', IS_OPTN); InvRegistry.RegisterParamInfo(TypeInfo(ServiceSoap), 'CriaContato', 'email', '', '', IS_OPTN); InvRegistry.RegisterParamInfo(TypeInfo(ServiceSoap), 'CriaContato', 'telefone', '', '', IS_OPTN); RemClassRegistry.RegisterXSClass(contato, 'http://tempuri.org/', 'contato');
end.
O meu delphi xe (build) é Embarcadero® Delphi® XE Version 15.0.3890.34076 O protocolo utilizado foi 1.0, autodetect e as opções do wsdl importer foram essas:
Me passe o source completo ou tente usar um eurekalog para obter um relatório mais detalhado do leak. Além da srvice.pas estar diferente, pode ser bug de alguma biblioteca do delphi. Eu não sei se é possível usar o fastMM4 no delphi xe, já que ele vem de fábrica com o fastmm.
Gostei + 0
12/05/2011
Marco Salles
Embarcadero® Delphi® XE Version 15.0.3953.35171 // Minha
Embarcadero® Delphi® XE Version 15.0.3890.34076 //sua
quanto a sua opções do wsdl importer que vc postou estão identicas a minha , porém no delphi 2010 ... 20 ITEMS
PORÉM NO DELPHI XE ESTA CONFIGURAÇOES NA VERSÃO 15.0.3953.35171 ESTÃO DIFERENTES ALÉM DE INCLUSÕES DE
ALGUNS ITÉMS .. 22 ITEMS ( NÃO TEM A OPÇÃO UNWIND LITERAL PARAMS *** QUARO ITEM MARCADO NAS OPÇOES
ANTERIORES
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)