Hi,

 

We are using Xerces-C++ (version 2.6) on Linux platform in our project “Device Agent software” for  XML parsing and persist the data in XML file at run time.

The Agent software will keep all the device configured data at run time in the DOM tree and for any read or write operation, this tree is traversed to fetch the data.

Also, to validate the incoming data, a small XML file is created and validated against the predefined XSDs.

I’m just trying to make it clear that, for any configuration request on the device, lots of XML operations are being done.

 

When we tried the Agent software memory leak analysis through Purify, we found that for every write operation, lot of memory (around 100KB each time)

is getting leaked.  For every write operation, Agent Software does creation of small XML file, parsing the same through SAX parser against the predefined

XSDs for data validation, loading this file using DOM parser to read the elements and finally update the data in the DOM tree which has the complete device configuration.

 

Following is the sample data of purify analysis.

Initially only XMLPlatformUtils::Initialize() was used for every write operation, we suspected this commented this line in the code. But still the leak is same.

We even tried using XMLPlatformUtils::Initialize() and XMLPlatformUtils::Terminate() for every write operation but memory leak is same.

 

Are we missing something? Is there some problem in the way we used the Xerces-C++ APIs? Are there  any apis to be called to free the Xerces allocated memory?

 

Any urgent help is highly appreciated.

 

Regards,

Siddesh

 

New memory leaked: 112020 bytes (3.04%); potentially leaked: 140 bytes (0.0038%)

         MLK: 65536 bytes leaked at 0x8788100

         This memory was allocated from:

               malloc         [rtlib.o]

               operator new(unsigned) [libstdc++.so.5]

               xercesc_2_6::MemoryManagerImpl::allocate(unsigned) [MemoryManagerImpl.cpp:46]

                  {

                      void* memptr;

                      try {

               =>         memptr = ::operator new(size);

                      }

                      catch(...) {

                          throw OutOfMemoryException();

               xercesc_2_6::DOMDocumentImpl::allocate(unsigned) [DOMDocumentImpl.cpp:850]

 

                          // Get a new block from the system allocator.

                          void* newBlock;

               =>         newBlock = fMemoryManager->allocate(kHeapAllocSize * sizeof(char)); //new char[kHeapAllocSize];

 

                          *(void **)newBlock = fCurrentBlock;

                          fCurrentBlock = newBlock;

               operator new(unsigned, xercesc_2_6::DOMDocument*) [DOMDocumentImpl.hpp:378]

                  inline void * operator new(size_t amt, XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc)

                  {

                      // revist.  Probably should be a checked cast.

               =>     void *p = ((XERCES_CPP_NAMESPACE_QUALIFIER DOMDocumentImpl *)doc)->allocate(amt);

                      return p;

                  }

 

               xercesc_2_6::DOMDocumentImpl::DOMDocumentImpl[not-in-charge](xercesc_2_6::MemoryManager*) [DOMDocumentImpl.cpp:90]

                        fChanges(0),

                        errorChecking(true)

                  {

               =>     fNamePool    = new (this) DOMStringPool(257, this);

                  }

 

 

         MLK: 12288 bytes leaked in 6 blocks

         MLK: 2048 bytes leaked at 0x863f0c8

 


The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

www.wipro.com

Reply via email to