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. 
 
 
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. 
 
Now I was able to delete xsd_string types, for an example:
 
setReturnAddPointsParameter::~setReturnAddPointsParameter()
{
  ...
 if(sBlpType != NULL){
   delete [] sBlpType;
 }
 sBlpType = 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)
{
...        
xsd__double * dAmount = NULL;
 if ((dAmount = pIWSDZ->getElementAsDouble( "dAmount",0)) != NULL){
    param->dAmount = *( dAmount );
    delete dAmount;
    dAmount = 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 ()
{
...   
  case XSD_STRING:
     if (AxisEngine::m_bServer){
        delete [] const_cast<char*>(m_Value.pStrValue);
     }
  break;
   ...
}     
 
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 -----
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.
 
I've next function which is called in multithreaded way:
 
setReturnAddPointsParameter* pRAPP = NULL;
MPBLPSoap pBLP_authorize(sMPG.strURL.c_str(), APTHTTP1_1);
pBLP_authorize.Timeout(10);
pRAPP = 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 = false, int nSize=0)
{
  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 ***".
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).  
 
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
 
 
 

Reply via email to