Return-Path: Delivered-To: apmail-ws-axis-c-user-archive@www.apache.org Received: (qmail 51689 invoked from network); 1 Nov 2005 18:39:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 1 Nov 2005 18:39:24 -0000 Received: (qmail 78372 invoked by uid 500); 1 Nov 2005 18:39:23 -0000 Delivered-To: apmail-ws-axis-c-user-archive@ws.apache.org Received: (qmail 78351 invoked by uid 500); 1 Nov 2005 18:39:22 -0000 Mailing-List: contact axis-c-user-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: "Apache AXIS C User List" Reply-To: "Apache AXIS C User List" Delivered-To: mailing list axis-c-user@ws.apache.org Received: (qmail 78338 invoked by uid 99); 1 Nov 2005 18:39:22 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Nov 2005 10:39:22 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [164.8.100.3] (HELO kukmak.uni-mb.si) (164.8.100.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Nov 2005 10:39:17 -0800 Received: from localhost (localhost [127.0.0.1]) by kukmak.uni-mb.si (Postfix) with ESMTP id A5924BEE0C for ; Tue, 1 Nov 2005 19:38:58 +0100 (CET) Received: from localhost ([127.0.0.1]) by localhost (kukmak.uni-mb.si [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 07293-05-3 for ; Tue, 1 Nov 2005 19:38:57 +0100 (CET) Received: from gandalf (dpgp57.uni-mb.si [164.8.3.57]) by kukmak.uni-mb.si (Postfix) with SMTP id DC162BEE0B for ; Tue, 1 Nov 2005 19:38:56 +0100 (CET) Message-ID: <000801c5df13$83f28950$390308a4@gandalf> From: "Tomaz Rotovnik" To: "Apache AXIS C User List" Subject: Memory Leak - solution Date: Tue, 1 Nov 2005 19:38:55 +0100 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0005_01C5DF1B.E5A4A1D0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Virus-Scanned: by amavisd-new / Sophos+Sophie & ClamAV at kukmak.uni-mb.si X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. ------=_NextPart_000_0005_01C5DF1B.E5A4A1D0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable Hello I would like to post some comments about memory handling with user = defined parameters (whith those that are send to the web server and = those that are received from the web server). In previous posts (see = mail below) I already mentioned memory leak, because user defined = parameters are never deleted.=20 Reason why I can't deleted allocated memory was in compiler settings: I = use setting "multithreaded run time library" instead of "multithreaded = DLL run time library". I think this should be mentioned (or alerted) = before users start developing their own examples. I spent one week to = figure this out. If this is already mentioned then I apologize.=20 Now I was able to delete xsd_string types, for an example: setReturnAddPointsParameter::~setReturnAddPointsParameter() { ... if(sBlpType !=3D NULL){ delete [] sBlpType; } sBlpType =3D NULL; ... } The problem was still with the xsd_double, xsd_int or similar types. I = put delete statement in Axis_DeSerialize_setReturnAddPointsParameter = method: int = Axis_DeSerialize_setReturnAddPointsParameter(setReturnAddPointsParameter*= param, IWrapperSoapDeSerializer* pIWSDZ) { ... =20 xsd__double * dAmount =3D NULL; if ((dAmount =3D pIWSDZ->getElementAsDouble( "dAmount",0)) !=3D NULL){ param->dAmount =3D *( dAmount ); delete dAmount; dAmount =3D NULL; } ... } The last thing was parameters of xsd_string type that are send to the = web server. They are added with statement addParameter for an example: m_pCall->addParameter((void*)Value1, "sMSISDN", XSD_STRING); Inside axis_dll there is new allocation created for those types, but it = is never deleted. I checked Param.cpp file and destructor statement: Param::~Param () { ... =20 case XSD_STRING: if (AxisEngine::m_bServer){ delete [] const_cast(m_Value.pStrValue); } break; ... } =20 So allocated memory is only deleted when Axis is initialized as server. = Why? With commenting this condition string data type is deleted with no = memory leak. Is this wrong? Best regards Tomaz Rotovnik ----- Original Message -----=20 From: Tomaz Rotovnik=20 To: Apache AXIS C User List=20 Sent: Friday, October 28, 2005 5:57 PM Subject: Memory Leak Hi again I'm trying to solve the problem with the memory leak on the client side = of axis library.=20 I've next function which is called in multithreaded way: setReturnAddPointsParameter* pRAPP =3D NULL; MPBLPSoap pBLP_authorize(sMPG.strURL.c_str(), APTHTTP1_1); pBLP_authorize.Timeout(10); pRAPP =3D pBLP_authorize.AddPoints(1,string_number,double_value); pRAPP is structure with next parameters: xsd__string sBlpType; xsd__double dAmount; xsd__string lTransactionID; The problem is how to delete allocated space for these parameters when I = don't needed it any more. There is defined delete function Axis_Delete_setReturnAddPointsParameter which is defined: void = Axis_Delete_setReturnAddPointsParameter(setReturnAddPointsParameter* = param, bool bArray =3D false, int nSize=3D0) { if (bArray) delete [] param; else delete param; } So I called this function when I want to delete allocated memory for = parameters. This function calls destructor: setReturnAddPointsParameter::~setReturnAddPointsParameter() { } which is empty. If I use statements delete or free inside destructor I = get the following error "User breakpoint called from code at ***".=20 So I checked how are basic types defined (xsd_string, xsd_double). They = are defined as classes and their destructors are empty. If I put delete = statements into these destructors then the result structure pRAPP is = empty, because parameters are deleted before they can be used = (destructor is called after calling this method: xsd__string SoapDeSerializer::getElementAsString (const AxisChar * pName, const = AxisChar * pNamespace). =20 So is it possible to delete allocated memory or is there a problem in = design structure of axis library? I mean is it possible to delete = allocated memory for basic type classes? Is solution in defining some = extra methods which they have access to those classes and they include = delete statement? Best regards Tomaz ------=_NextPart_000_0005_01C5DF1B.E5A4A1D0 Content-Type: text/html; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable
Hello
 
I would like to post some comments = about memory=20 handling with user defined parameters (whith those that are send to = the web=20 server and those that are received from the web server). In = previous posts=20 (see mail below) I already mentioned memory leak, because user defined=20 parameters are never deleted. 
 
 
Reason why I can't deleted allocated = memory was=20 in compiler settings: I use setting "multithreaded run time = library"=20 instead of "multithreaded DLL run time library". I think this = should=20 be mentioned (or alerted) before users start developing their = own examples.=20 I spent one week to figure this out. If this is already mentioned then I = apologize. 
 
Now I was able to delete xsd_string = types, for an=20 example:
 
setReturnAddPointsParameter::~setReturnAddPointsParameter()
{=
  ...
 if(sBlpType=20 !=3D NULL){
   delete [] = sBlpType;
 }
 sBlpType =3D=20 NULL;
...
}
The problem was still with = the xsd_double,=20 xsd_int or similar types. I put delete statement in=20 Axis_DeSerialize_setReturnAddPointsParameter method:
 
 
int=20 Axis_DeSerialize_setReturnAddPointsParameter(setReturnAddPointsParameter*= param,=20 IWrapperSoapDeSerializer* pIWSDZ)
{
...        
=
xsd__double * dAmount =3D = NULL;
 if ((dAmount=20 =3D pIWSDZ->getElementAsDouble( "dAmount",0)) !=3D = NULL){
   =20 param->dAmount =3D *( dAmount );
    delete=20 dAmount;
    dAmount =3D NULL;
 }
...
}
 
The last thing was parameters of = xsd_string type=20 that are send to the web server. They are added with statement = addParameter for=20 an example:
 
m_pCall->addParameter((void*)Value1, = "sMSISDN",=20 XSD_STRING);
 
Inside axis_dll there is new allocation = created for=20 those types, but it is never deleted. I checked Param.cpp file and = destructor=20 statement:
 
Param::~Param=20 ()
{
...   
  case=20 XSD_STRING:
     if=20 (AxisEngine::m_bServer){
       &nb= sp;delete=20 []=20 const_cast<char*>(m_Value.pStrValue);
    &n= bsp;}
  break;
   ...
}     
 
So allocated memory is only deleted = when Axis is=20 initialized as server. Why? With commenting this condition string data = type is=20 deleted with no memory leak.
Is this wrong?
 
Best regards
 
Tomaz Rotovnik
 
 
 
 
 
----- Original Message -----=20
From: Tomaz=20 Rotovnik
Sent: Friday, October 28, 2005 5:57 PM
Subject: Memory Leak

Hi again
 
I'm trying to solve the problem with = the memory=20 leak on the client side of axis library.
 
I've next function which is called in = multithreaded=20 way:
 
setReturnAddPointsParameter* pRAPP =3D NULL;
MPBLPSoap=20 pBLP_authorize(sMPG.strURL.c_str(),=20 APTHTTP1_1);
pBLP_authorize.Timeout(10);
pRAPP =3D=20 pBLP_authorize.AddPoints(1,string_number,double_value);
 
pRAPP is structure with next=20 parameters:
xsd__string sBlpType;
xsd__double dAmount;
xsd__string=20 lTransactionID;
The problem is how to delete allocated = space for=20 these parameters when I don't needed it any more. There is defined = delete=20 function
Axis_Delete_setReturnAddPointsParameter which is defined:
 
void=20 Axis_Delete_setReturnAddPointsParameter(setReturnAddPointsParameter* = param, bool=20 bArray =3D false, int nSize=3D0)
{
  if=20 (bArray)
     = delete []=20 param;
 else
     delete = param;
}
 
So I called this function when I want = to delete=20 allocated memory for parameters. This function calls = destructor:
setReturnAddPointsParameter::~setReturnAddPointsParameter()
{=
}
 
which is empty. If I use statements = delete or free=20 inside destructor I get the following error "User breakpoint called from = code at=20 ***".
So I checked how are basic types = defined=20 (xsd_string, xsd_double). They are = defined as=20 classes and their destructors are empty. If I put delete statements into = these=20 destructors then the result structure pRAPP is empty, = because parameters=20 are deleted before they can be used (destructor is called after calling = this=20 method: xsd__string
SoapDeSerializer::getElementAsString (const = AxisChar *=20 pName, const AxisChar * pNamespace).  
 
So is it possible to delete allocated memory or is there a problem = in design=20 structure of axis library? I mean is it possible to delete allocated = memory for=20 basic type classes? Is solution in defining some extra methods which = they have=20 access to those classes and they include delete statement?
 
Best regards
 
Tomaz
 
 
 
------=_NextPart_000_0005_01C5DF1B.E5A4A1D0--