axis-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Susantha Kumara" <susan...@opensource.lk>
Subject RE: memory management and AXIS_DEFINED_ARRAY
Date Tue, 01 Jun 2004 09:57:32 GMT
Hi Alek,

> -----Original Message-----
> From: Aleksander Slominski [mailto:aslom@cs.indiana.edu]
> Sent: Saturday, May 29, 2004 5:30 AM
> To: Apache AXIS C Developers List
> Subject: Re: memory management and AXIS_DEFINED_ARRAY
> 
> followup: it seems that skeleton is just calling
> 
>     pIWSSZ->addOutputBasicArrayParam((Axis_Array*)(&ret),XSD_INT,
> "echoIntsReturn");
> 
> after looking it in source code it seems thta is acutally called isL
> 
> SoapSerializer::addOutputBasicArrayParam(const Axis_Array* pArray,
>                                              XSDTYPE nType,
>                                              const AxisChar* pName)
> 
> which as far as i can tell does not deallocate pArray?

After sending a response(at server side) or after sending request (at
client side the Serializer object used is pooled back to be re-used.
When a Serializer object gets pooled its init() is called. Inside this
function this de-allocation of the objects is started. Eventually the
SoapMethod object's destructor is called where all added (serialized)
structures are deleted/deallocated.

See,

SoapMethod::~SoapMethod()
Param::~Param ()
And
ArrayBean::~ArrayBean()

---
Susantha

> 
> is it memory leak for sendInts?
> 
> if i have 3 methods like this what is the right way to manage memory
(by
> caller)?
> 
>         xsd__int_Array echoInts(xsd__int_Array Value0);
>         int receiveInts(xsd__int_Array Value0);
>         xsd__int_Array sendInts(int Value0);
> 
> thanks,
> 
> alek
> 
> 
> int Benchmark1PortTypeWrapper::sendInts(void* pMsg)
> {
>     IMessageData* mc = (IMessageData*)pMsg;
>     int nStatus;
>     IWrapperSoapSerializer *pIWSSZ = NULL;
>     mc->getSoapSerializer(&pIWSSZ);
>     if (!pIWSSZ) return AXIS_FAIL;
>     IWrapperSoapDeSerializer *pIWSDZ = NULL;
>     mc->getSoapDeSerializer(&pIWSDZ);
>     if (!pIWSDZ) return AXIS_FAIL;
>     /* check whether we have got correct message */
>     if (AXIS_SUCCESS != pIWSDZ->checkMessageBody("sendInts",
> "http://www.extreme.indiana.edu/wsdl/Benchmark1.wsdl")) return
AXIS_FAIL;
>     pIWSSZ->createSoapMethod("sendIntsResponse",
> "http://www.extreme.indiana.edu/wsdl/Benchmark1.wsdl");
>     int v0 = pIWSDZ->getElementAsInt("size",0);
>     if (AXIS_SUCCESS != (nStatus = pIWSDZ->getStatus())) return
nStatus;
>     xsd__int_Array ret = pWs->sendInts(v0);
>     return
pIWSSZ->addOutputBasicArrayParam((Axis_Array*)(&ret),XSD_INT,
> "sendIntsReturn");
> }
> 
> 
> int SoapSerializer::addOutputBasicArrayParam(const Axis_Array* pArray,
>                                              XSDTYPE nType,
>                                              const AxisChar* pName)
> {
>     IArrayBean* pAb = makeArrayBean(nType, (void*)(pArray->m_Array));
>     pAb->SetDimension(pArray->m_Size);
>     Param* pParam = new Param();
>     if (RPC_ENCODED == m_nStyle)
>     {
>         pAb->SetItemName("item");
>         pParam->setName(pName);
>     }
>     else
>     {
>         pAb->SetItemName(pName);
>         pParam->setName("array");
>     }
>     pParam->m_Value.pIArray = pAb;
>     pParam->m_Type = XSD_ARRAY;
>     if(m_pSoapEnvelope && (m_pSoapEnvelope->m_pSoapBody) &&
>         (m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod))
>     {
>         m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod-
> >addOutputParam(pParam);
>     }
>     return AXIS_SUCCESS;
> }
> 
> 
> IArrayBean* SoapSerializer::makeArrayBean(XSDTYPE nType, void* pArray)
> {
>     ArrayBean* pAb = new ArrayBean();
>     pAb->m_type = nType;
>     pAb->m_value.sta = pArray;
>     return pAb;
> }
> Aleksander Slominski wrote:
> 
> > hi,
> >
> > how is it supposed to be used - if i return new allocated
> > AXIS_DEFINED_ARRAY will it be automatically deallocated?!
> >
> > for example is this valid way to do echo? i have seen it in
> > InteropTestPortType.cpp so that should be fine though in this case i
> > do not understand who is de-allocating memory as xsd__int_Array is
> > passed as input and returned as output? shouldnt service clone the
> > array or auto pointer be used?
> >
> > xsd__int_Array Benchmark1PortType::echoInts(xsd__int_Array Value0)
> > {
> >    return Value0;
> > }
> >
> > and what about returning new value?
> >
> > xsd__int_Array Benchmark1PortType::sendInts(int length)
> > {
> >    xsd__int_Array arr;
> >    arr.m_Size = length;
> >    arr.m_Array = (int *) malloc(length * sizeof(int));
> >    // fill in array with values
> >    return arr;
> > }
> >
> > will it be de-allocated? do i miss something (documentation,
examples)?
> >
> > thanks,
> >
> > alek
> >
> 
> 
> --
> The best way to predict the future is to invent it - Alan Kay



Mime
View raw message