You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-user@axis.apache.org by "Kelly, Niall" <Ni...@ie.fid-intl.com> on 2006/08/08 19:06:43 UTC

Re: Destruction of ArrayBean -- Memory Leak?

Hi,

I have encountered memory leaks (reported by Purify (on Solaris) and
Valgrind (on Linux)) in an AXIS C++ Client application. The leaks are
associated with a clone of an array object (created by the
SoapSerializer::addOutputCmplxArrayParam method). The cloned object is used
to call makeArrayBean after which the clone is "de-coupled" -- i.e its
internal m_Size and m_Array fields are reset before it is destroyed. I
understand that the idea of this is that the clone object itself is cleaned
up and the ArrayBean object takes ownership of the internal array.

After the Web-service operation has been invoked, the ArrayBean destructor
will eventually be called. In the destructor a number of checks are made
(see below) before the appropriate delete-function (in generated stub)  is
made. As earlier raised by Yuan Liu, why is this delete function not invoked
for client side AXIS C++ apps? (If I remove the check for
AxisEngine::m_bServer in the ArrayBean destructor the tools I use no longer
report leaks for my application).

Should this change be made to the AXIS C++ source or are there potential
issues with allowing this delete on client-side?

Regards,
Niall.

    // Extract from ~ArrayBean
    if (USER_TYPE == m_type)
    {
        if (m_value.cta)
        {
            if (m_value.cta->pObject)
            {
              if (AxisEngine::m_bServer)
                {
                    m_value.cta->pDelFunct(m_value.cta->pObject, true,
m_nSize);
                }
                // make sure that the ComplexObjectHandler's destructor does

                // not try to delete the objects again 
                m_value.cta->pObject = NULL;
            }
            delete m_value.cta;
            m_value.cta = NULL;
        }
    }

	 -----Original Message-----

	Hi,
	
	I just want to know is there a reason why ArrayBeans are only
deleted on the
	Server as the destructor contains codes like "if
(AxisEngine::m_bServer)".
	At the moment, the client is leaking memory whenever it calls
	"addOutputBasicArrayParam" (SoapSerializer.cpp) which create an
ArrayBean
	with reference to an allocated block of Axis_Array. The ArrayBean is
deleted
	correctly on server side but client side it is not deleted.
	
	Thanks for all the good work.
	
	Regards,
	
	Yuan Liu