[jira] Created: (XERCESC-1589) XML DOM parser does not release memory on parser:release and resetDocumentPool()

View: New views
11 Messages — Rating Filter:   Alert me  

[jira] Created: (XERCESC-1589) XML DOM parser does not release memory on parser:release and resetDocumentPool()

by JIRA xerces-c-dev@xml.apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

XML DOM parser does not release memory on parser:release and resetDocumentPool()
--------------------------------------------------------------------------------

         Key: XERCESC-1589
         URL: http://issues.apache.org/jira/browse/XERCESC-1589
     Project: Xerces-C++
        Type: Bug

  Components: DOM  
    Versions: 2.4.0    
 Environment: HP-Tandem-NonStop Kernel

    Reporter: Rinil Baxi


1) Use the following code:

/home/Rinil/Xml/dom [2441]: more mleak.cpp
#include < string.h>
#include < cextdecs.h>
#include < iostream>
#include < xercesc/util/PlatformUtils.hpp>
#include < xercesc/parsers/AbstractDOMParser.hpp>
#include < xercesc/dom/DOMImplementation.hpp>
#include < xercesc/dom/DOMImplementationLS.hpp>
#include < xercesc/dom/DOMImplementationRegistry.hpp>
#include < xercesc/dom/DOMBuilder.hpp>
#include < xercesc/dom/DOMException.hpp>
#include < xercesc/dom/DOMDocument.hpp>
#include < xercesc/dom/DOMNodeList.hpp>
#include < xercesc/dom/DOMError.hpp>
#include < xercesc/dom/DOMLocator.hpp>
#include < xercesc/dom/DOMWriter.hpp>
#include < xercesc/framework/StdOutFormatTarget.hpp>
#include < xercesc/framework/LocalFileFormatTarget.hpp>
#include < xercesc/framework/MemBufInputSource.hpp>
#include < xercesc/framework/Wrapper4InputSource.hpp>
#include < xercesc/parsers/XercesDOMParser.hpp>
#include < xercesc/util/XMLUni.hpp>
#include < xercesc/util/XMLException.hpp>


unsigned long getMemUsage ()
{
 short gError = 0;
 short myHandle[10];
 short attrList[10];
 short valList[10];
 short valMaxLen = 10;
 short valLen = 0;
 short attrs = 0;

 unsigned long *memUsage;

 gError = PROCESSHANDLE_GETMINE_ (&myHandle[0]);

 if (gError)
  return 0;35%)

 memset (&attrList[0], '\0', 10);

 memset (&valList[0], '\0', 10);

 attrList[attrs] = 111;
 attrs++;

 gError = PROCESS_GETINFOLIST_
  (,,,,&myHandle[0]
  ,&attrList[0]
  ,attrs
  ,&valList[0]
  ,valMaxLen
  ,&valLen
  );

 if (gError)
  return 0;

 memUsage = (unsigned long *) (&valList[0]);

 return *memUsage;

}

int main()
{
 DOMImplementation *impl;
 DOMBuilder *parser;
 DOMDocument *doc;

 const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull };

 std::cout < < "\nMEMUSAGE at Start : "< < getMemUsage();

 // Initialize the XML system
 try {
        XMLPlatformUtils::Initialize();
        XMLPlatformUtils::recognizeNEL(false);
  }

 catch (const XMLException& toCatch) {
          return 1;
 }

 impl = DOMImplementationRegistry::getDOMImplementation(gLS);

 parser = ((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0);

 if (parser == NULL) {
  //Its known that XML system must be terminated before returning
  return 1;
 }

 parser->setFeature(XMLUni::fgDOMNamespaces,true);
 parser->setFeature(XMLUni::fgXercesSchema, false);
 parser->setFeature(XMLUni::fgXercesSchemaFullChecking, false);
 parser->setFeature(XMLUni::fgDOMValidateIfSchema, false);
 parser->setFeature(XMLUni::fgDOMDatatypeNormalization, true);

 //Reset Document Pool
 parser->resetDocumentPool();

 std::cout< < "\nMEMUSAGE before parsing: "< < getMemUsage();

 //Parse XML and get document
 try{
  doc = parser->parseURI("personal.xml");
 }
 catch(DOMException dome){
  //Its known that XML system must be terminated before returning
  return 1;
 }

 std::cout< < "\nMEMUSAGE after parsing: "< < getMemUsage();
 //Reset Document Pool
 parser->resetDocumentPool();
 std::cout< < "\nMEMUSAGE after resetDocumentpool(): "< < getMemUsage();

 //Release Parser
 //This should also release DOMDOcument associated i.e. doc
 parser->release();

 std::cout< < "\nMEMUSAGE after parser release(): "< < getMemUsage();

 XMLPlatformUtils::Terminate();

 std::cout< < "\nMEMUSAGE after Terminate(): "< < getMemUsage()< < std::endl;

 return 0;

}

/home/Rinil/xml/dom [2442]:

2) Compile using Makefiles provided with XML samples.

3) Place a xml file to be parsed in the CWD. ie personal.xml which comes with
the samples.

4) run mleak:

/home/RinilXml/dom [2452]: ./mleak

MEMUSAGE at Start : 16384
MEMUSAGE before parsing: 57344
MEMUSAGE after parsing: 245888
MEMUSAGE after resetDocumentpool(): 245888
MEMUSAGE after parser release(): 245888
MEMUSAGE after Terminate(): 245888


--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@...
For additional commands, e-mail: c-dev-help@...


[jira] Commented: (XERCESC-1589) XML DOM parser does not release memory on parser:release and resetDocumentPool()

by JIRA xerces-c-dev@xml.apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

    [ http://issues.apache.org/jira/browse/XERCESC-1589?page=comments#action_12376182 ]

Rinil Baxi commented on XERCESC-1589:
-------------------------------------

We have an application that creates response XML on fly for communication.
       
The problem we are facing is that memory is not being released when we release
DOMBuilder. We tried using various different ways of releasing memory including
resetDocumentPool( ), release( ) and even Terminate( ) but alas no luck.  We have
also found few excerpts on web talking about this issue and saying that
it depends on garbage collector policies.

The test case provided here can easily reproduce the problem.



> XML DOM parser does not release memory on parser:release and resetDocumentPool()
> --------------------------------------------------------------------------------
>
>          Key: XERCESC-1589
>          URL: http://issues.apache.org/jira/browse/XERCESC-1589
>      Project: Xerces-C++
>         Type: Bug

>   Components: DOM
>     Versions: 2.4.0
>  Environment: HP-Tandem-NonStop Kernel
>     Reporter: Rinil Baxi

>
> 1) Use the following code:
> /home/Rinil/Xml/dom [2441]: more mleak.cpp
> #include < string.h>
> #include < cextdecs.h>
> #include < iostream>
> #include < xercesc/util/PlatformUtils.hpp>
> #include < xercesc/parsers/AbstractDOMParser.hpp>
> #include < xercesc/dom/DOMImplementation.hpp>
> #include < xercesc/dom/DOMImplementationLS.hpp>
> #include < xercesc/dom/DOMImplementationRegistry.hpp>
> #include < xercesc/dom/DOMBuilder.hpp>
> #include < xercesc/dom/DOMException.hpp>
> #include < xercesc/dom/DOMDocument.hpp>
> #include < xercesc/dom/DOMNodeList.hpp>
> #include < xercesc/dom/DOMError.hpp>
> #include < xercesc/dom/DOMLocator.hpp>
> #include < xercesc/dom/DOMWriter.hpp>
> #include < xercesc/framework/StdOutFormatTarget.hpp>
> #include < xercesc/framework/LocalFileFormatTarget.hpp>
> #include < xercesc/framework/MemBufInputSource.hpp>
> #include < xercesc/framework/Wrapper4InputSource.hpp>
> #include < xercesc/parsers/XercesDOMParser.hpp>
> #include < xercesc/util/XMLUni.hpp>
> #include < xercesc/util/XMLException.hpp>
> unsigned long getMemUsage ()
> {
>  short gError = 0;
>  short myHandle[10];
>  short attrList[10];
>  short valList[10];
>  short valMaxLen = 10;
>  short valLen = 0;
>  short attrs = 0;
>  unsigned long *memUsage;
>  gError = PROCESSHANDLE_GETMINE_ (&myHandle[0]);
>  if (gError)
>   return 0;35%)
>  memset (&attrList[0], '\0', 10);
>  memset (&valList[0], '\0', 10);
>  attrList[attrs] = 111;
>  attrs++;
>  gError = PROCESS_GETINFOLIST_
>   (,,,,&myHandle[0]
>   ,&attrList[0]
>   ,attrs
>   ,&valList[0]
>   ,valMaxLen
>   ,&valLen
>   );
>  if (gError)
>   return 0;
>  memUsage = (unsigned long *) (&valList[0]);
>  return *memUsage;
> }
> int main()
> {
>  DOMImplementation *impl;
>  DOMBuilder *parser;
>  DOMDocument *doc;
>  const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull };
>  std::cout < < "\nMEMUSAGE at Start : "< < getMemUsage();
>  // Initialize the XML system
>  try {
>         XMLPlatformUtils::Initialize();
>         XMLPlatformUtils::recognizeNEL(false);
>   }
>  catch (const XMLException& toCatch) {
>           return 1;
>  }
>  impl = DOMImplementationRegistry::getDOMImplementation(gLS);
>  parser = ((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0);
>  if (parser == NULL) {
>   //Its known that XML system must be terminated before returning
>   return 1;
>  }
>  parser->setFeature(XMLUni::fgDOMNamespaces,true);
>  parser->setFeature(XMLUni::fgXercesSchema, false);
>  parser->setFeature(XMLUni::fgXercesSchemaFullChecking, false);
>  parser->setFeature(XMLUni::fgDOMValidateIfSchema, false);
>  parser->setFeature(XMLUni::fgDOMDatatypeNormalization, true);
>  //Reset Document Pool
>  parser->resetDocumentPool();
>  std::cout< < "\nMEMUSAGE before parsing: "< < getMemUsage();
>  //Parse XML and get document
>  try{
>   doc = parser->parseURI("personal.xml");
>  }
>  catch(DOMException dome){
>   //Its known that XML system must be terminated before returning
>   return 1;
>  }
>  std::cout< < "\nMEMUSAGE after parsing: "< < getMemUsage();
>  //Reset Document Pool
>  parser->resetDocumentPool();
>  std::cout< < "\nMEMUSAGE after resetDocumentpool(): "< < getMemUsage();
>  //Release Parser
>  //This should also release DOMDOcument associated i.e. doc
>  parser->release();
>  std::cout< < "\nMEMUSAGE after parser release(): "< < getMemUsage();
>  XMLPlatformUtils::Terminate();
>  std::cout< < "\nMEMUSAGE after Terminate(): "< < getMemUsage()< < std::endl;
>  return 0;
> }
> /home/Rinil/xml/dom [2442]:
> 2) Compile using Makefiles provided with XML samples.
> 3) Place a xml file to be parsed in the CWD. ie personal.xml which comes with
> the samples.
> 4) run mleak:
> /home/RinilXml/dom [2452]: ./mleak
> MEMUSAGE at Start : 16384
> MEMUSAGE before parsing: 57344
> MEMUSAGE after parsing: 245888
> MEMUSAGE after resetDocumentpool(): 245888
> MEMUSAGE after parser release(): 245888
> MEMUSAGE after Terminate(): 245888

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@...
For additional commands, e-mail: c-dev-help@...


[jira] Commented: (XERCESC-1589) XML DOM parser does not release memory on parser:release and resetDocumentPool()

by JIRA xerces-c-dev@xml.apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

    [ http://issues.apache.org/jira/browse/XERCESC-1589?page=comments#action_12376183 ]

Gareth Reakes commented on XERCESC-1589:
----------------------------------------

Hi,

       As per my email, have you tried the most recent version of Xerces? Lots of work has happened since 2.4.

Gareth

> XML DOM parser does not release memory on parser:release and resetDocumentPool()
> --------------------------------------------------------------------------------
>
>          Key: XERCESC-1589
>          URL: http://issues.apache.org/jira/browse/XERCESC-1589
>      Project: Xerces-C++
>         Type: Bug

>   Components: DOM
>     Versions: 2.4.0
>  Environment: HP-Tandem-NonStop Kernel
>     Reporter: Rinil Baxi

>
> 1) Use the following code:
> /home/Rinil/Xml/dom [2441]: more mleak.cpp
> #include < string.h>
> #include < cextdecs.h>
> #include < iostream>
> #include < xercesc/util/PlatformUtils.hpp>
> #include < xercesc/parsers/AbstractDOMParser.hpp>
> #include < xercesc/dom/DOMImplementation.hpp>
> #include < xercesc/dom/DOMImplementationLS.hpp>
> #include < xercesc/dom/DOMImplementationRegistry.hpp>
> #include < xercesc/dom/DOMBuilder.hpp>
> #include < xercesc/dom/DOMException.hpp>
> #include < xercesc/dom/DOMDocument.hpp>
> #include < xercesc/dom/DOMNodeList.hpp>
> #include < xercesc/dom/DOMError.hpp>
> #include < xercesc/dom/DOMLocator.hpp>
> #include < xercesc/dom/DOMWriter.hpp>
> #include < xercesc/framework/StdOutFormatTarget.hpp>
> #include < xercesc/framework/LocalFileFormatTarget.hpp>
> #include < xercesc/framework/MemBufInputSource.hpp>
> #include < xercesc/framework/Wrapper4InputSource.hpp>
> #include < xercesc/parsers/XercesDOMParser.hpp>
> #include < xercesc/util/XMLUni.hpp>
> #include < xercesc/util/XMLException.hpp>
> unsigned long getMemUsage ()
> {
>  short gError = 0;
>  short myHandle[10];
>  short attrList[10];
>  short valList[10];
>  short valMaxLen = 10;
>  short valLen = 0;
>  short attrs = 0;
>  unsigned long *memUsage;
>  gError = PROCESSHANDLE_GETMINE_ (&myHandle[0]);
>  if (gError)
>   return 0;35%)
>  memset (&attrList[0], '\0', 10);
>  memset (&valList[0], '\0', 10);
>  attrList[attrs] = 111;
>  attrs++;
>  gError = PROCESS_GETINFOLIST_
>   (,,,,&myHandle[0]
>   ,&attrList[0]
>   ,attrs
>   ,&valList[0]
>   ,valMaxLen
>   ,&valLen
>   );
>  if (gError)
>   return 0;
>  memUsage = (unsigned long *) (&valList[0]);
>  return *memUsage;
> }
> int main()
> {
>  DOMImplementation *impl;
>  DOMBuilder *parser;
>  DOMDocument *doc;
>  const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull };
>  std::cout < < "\nMEMUSAGE at Start : "< < getMemUsage();
>  // Initialize the XML system
>  try {
>         XMLPlatformUtils::Initialize();
>         XMLPlatformUtils::recognizeNEL(false);
>   }
>  catch (const XMLException& toCatch) {
>           return 1;
>  }
>  impl = DOMImplementationRegistry::getDOMImplementation(gLS);
>  parser = ((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0);
>  if (parser == NULL) {
>   //Its known that XML system must be terminated before returning
>   return 1;
>  }
>  parser->setFeature(XMLUni::fgDOMNamespaces,true);
>  parser->setFeature(XMLUni::fgXercesSchema, false);
>  parser->setFeature(XMLUni::fgXercesSchemaFullChecking, false);
>  parser->setFeature(XMLUni::fgDOMValidateIfSchema, false);
>  parser->setFeature(XMLUni::fgDOMDatatypeNormalization, true);
>  //Reset Document Pool
>  parser->resetDocumentPool();
>  std::cout< < "\nMEMUSAGE before parsing: "< < getMemUsage();
>  //Parse XML and get document
>  try{
>   doc = parser->parseURI("personal.xml");
>  }
>  catch(DOMException dome){
>   //Its known that XML system must be terminated before returning
>   return 1;
>  }
>  std::cout< < "\nMEMUSAGE after parsing: "< < getMemUsage();
>  //Reset Document Pool
>  parser->resetDocumentPool();
>  std::cout< < "\nMEMUSAGE after resetDocumentpool(): "< < getMemUsage();
>  //Release Parser
>  //This should also release DOMDOcument associated i.e. doc
>  parser->release();
>  std::cout< < "\nMEMUSAGE after parser release(): "< < getMemUsage();
>  XMLPlatformUtils::Terminate();
>  std::cout< < "\nMEMUSAGE after Terminate(): "< < getMemUsage()< < std::endl;
>  return 0;
> }
> /home/Rinil/xml/dom [2442]:
> 2) Compile using Makefiles provided with XML samples.
> 3) Place a xml file to be parsed in the CWD. ie personal.xml which comes with
> the samples.
> 4) run mleak:
> /home/RinilXml/dom [2452]: ./mleak
> MEMUSAGE at Start : 16384
> MEMUSAGE before parsing: 57344
> MEMUSAGE after parsing: 245888
> MEMUSAGE after resetDocumentpool(): 245888
> MEMUSAGE after parser release(): 245888
> MEMUSAGE after Terminate(): 245888

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@...
For additional commands, e-mail: c-dev-help@...


[jira] Commented: (XERCESC-1589) XML DOM parser does not release memory on parser:release and resetDocumentPool()

by JIRA xerces-c-dev@xml.apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

    [ http://issues.apache.org/jira/browse/XERCESC-1589?page=comments#action_12414055 ]

Rinil Baxi commented on XERCESC-1589:
-------------------------------------

Hi,

I am using Xercesc Parser 2.4.0.
The problem (XERCESC-1260 : Memory not released with DOMBuilder::parse() method) persists with the version I am using.
Please guide me,  How I can resolve this problem in 2.4.0.

I am not able to use the latest versions due to some production problems.

Kindly reply as soon as possible.

Thanks and Best Regards,
Rinil

> XML DOM parser does not release memory on parser:release and resetDocumentPool()
> --------------------------------------------------------------------------------
>
>          Key: XERCESC-1589
>          URL: http://issues.apache.org/jira/browse/XERCESC-1589
>      Project: Xerces-C++
>         Type: Bug

>   Components: DOM
>     Versions: 2.4.0
>  Environment: HP-Tandem-NonStop Kernel
>     Reporter: Rinil Baxi

>
> 1) Use the following code:
> /home/Rinil/Xml/dom [2441]: more mleak.cpp
> #include < string.h>
> #include < cextdecs.h>
> #include < iostream>
> #include < xercesc/util/PlatformUtils.hpp>
> #include < xercesc/parsers/AbstractDOMParser.hpp>
> #include < xercesc/dom/DOMImplementation.hpp>
> #include < xercesc/dom/DOMImplementationLS.hpp>
> #include < xercesc/dom/DOMImplementationRegistry.hpp>
> #include < xercesc/dom/DOMBuilder.hpp>
> #include < xercesc/dom/DOMException.hpp>
> #include < xercesc/dom/DOMDocument.hpp>
> #include < xercesc/dom/DOMNodeList.hpp>
> #include < xercesc/dom/DOMError.hpp>
> #include < xercesc/dom/DOMLocator.hpp>
> #include < xercesc/dom/DOMWriter.hpp>
> #include < xercesc/framework/StdOutFormatTarget.hpp>
> #include < xercesc/framework/LocalFileFormatTarget.hpp>
> #include < xercesc/framework/MemBufInputSource.hpp>
> #include < xercesc/framework/Wrapper4InputSource.hpp>
> #include < xercesc/parsers/XercesDOMParser.hpp>
> #include < xercesc/util/XMLUni.hpp>
> #include < xercesc/util/XMLException.hpp>
> unsigned long getMemUsage ()
> {
>  short gError = 0;
>  short myHandle[10];
>  short attrList[10];
>  short valList[10];
>  short valMaxLen = 10;
>  short valLen = 0;
>  short attrs = 0;
>  unsigned long *memUsage;
>  gError = PROCESSHANDLE_GETMINE_ (&myHandle[0]);
>  if (gError)
>   return 0;35%)
>  memset (&attrList[0], '\0', 10);
>  memset (&valList[0], '\0', 10);
>  attrList[attrs] = 111;
>  attrs++;
>  gError = PROCESS_GETINFOLIST_
>   (,,,,&myHandle[0]
>   ,&attrList[0]
>   ,attrs
>   ,&valList[0]
>   ,valMaxLen
>   ,&valLen
>   );
>  if (gError)
>   return 0;
>  memUsage = (unsigned long *) (&valList[0]);
>  return *memUsage;
> }
> int main()
> {
>  DOMImplementation *impl;
>  DOMBuilder *parser;
>  DOMDocument *doc;
>  const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull };
>  std::cout < < "\nMEMUSAGE at Start : "< < getMemUsage();
>  // Initialize the XML system
>  try {
>         XMLPlatformUtils::Initialize();
>         XMLPlatformUtils::recognizeNEL(false);
>   }
>  catch (const XMLException& toCatch) {
>           return 1;
>  }
>  impl = DOMImplementationRegistry::getDOMImplementation(gLS);
>  parser = ((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0);
>  if (parser == NULL) {
>   //Its known that XML system must be terminated before returning
>   return 1;
>  }
>  parser->setFeature(XMLUni::fgDOMNamespaces,true);
>  parser->setFeature(XMLUni::fgXercesSchema, false);
>  parser->setFeature(XMLUni::fgXercesSchemaFullChecking, false);
>  parser->setFeature(XMLUni::fgDOMValidateIfSchema, false);
>  parser->setFeature(XMLUni::fgDOMDatatypeNormalization, true);
>  //Reset Document Pool
>  parser->resetDocumentPool();
>  std::cout< < "\nMEMUSAGE before parsing: "< < getMemUsage();
>  //Parse XML and get document
>  try{
>   doc = parser->parseURI("personal.xml");
>  }
>  catch(DOMException dome){
>   //Its known that XML system must be terminated before returning
>   return 1;
>  }
>  std::cout< < "\nMEMUSAGE after parsing: "< < getMemUsage();
>  //Reset Document Pool
>  parser->resetDocumentPool();
>  std::cout< < "\nMEMUSAGE after resetDocumentpool(): "< < getMemUsage();
>  //Release Parser
>  //This should also release DOMDOcument associated i.e. doc
>  parser->release();
>  std::cout< < "\nMEMUSAGE after parser release(): "< < getMemUsage();
>  XMLPlatformUtils::Terminate();
>  std::cout< < "\nMEMUSAGE after Terminate(): "< < getMemUsage()< < std::endl;
>  return 0;
> }
> /home/Rinil/xml/dom [2442]:
> 2) Compile using Makefiles provided with XML samples.
> 3) Place a xml file to be parsed in the CWD. ie personal.xml which comes with
> the samples.
> 4) run mleak:
> /home/RinilXml/dom [2452]: ./mleak
> MEMUSAGE at Start : 16384
> MEMUSAGE before parsing: 57344
> MEMUSAGE after parsing: 245888
> MEMUSAGE after resetDocumentpool(): 245888
> MEMUSAGE after parser release(): 245888
> MEMUSAGE after Terminate(): 245888

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@...
For additional commands, e-mail: c-dev-help@...


[jira] Commented: (XERCESC-1589) XML DOM parser does not release memory on parser:release and resetDocumentPool()

by JIRA xerces-c-dev@xml.apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

    [ http://issues.apache.org/jira/browse/XERCESC-1589?page=comments#action_12414059 ]

Rinil Baxi commented on XERCESC-1589:
-------------------------------------

Hi,

Even I have tried out the same with latest versions but not success.

Rinil

> XML DOM parser does not release memory on parser:release and resetDocumentPool()
> --------------------------------------------------------------------------------
>
>          Key: XERCESC-1589
>          URL: http://issues.apache.org/jira/browse/XERCESC-1589
>      Project: Xerces-C++
>         Type: Bug

>   Components: DOM
>     Versions: 2.4.0
>  Environment: HP-Tandem-NonStop Kernel
>     Reporter: Rinil Baxi

>
> 1) Use the following code:
> /home/Rinil/Xml/dom [2441]: more mleak.cpp
> #include < string.h>
> #include < cextdecs.h>
> #include < iostream>
> #include < xercesc/util/PlatformUtils.hpp>
> #include < xercesc/parsers/AbstractDOMParser.hpp>
> #include < xercesc/dom/DOMImplementation.hpp>
> #include < xercesc/dom/DOMImplementationLS.hpp>
> #include < xercesc/dom/DOMImplementationRegistry.hpp>
> #include < xercesc/dom/DOMBuilder.hpp>
> #include < xercesc/dom/DOMException.hpp>
> #include < xercesc/dom/DOMDocument.hpp>
> #include < xercesc/dom/DOMNodeList.hpp>
> #include < xercesc/dom/DOMError.hpp>
> #include < xercesc/dom/DOMLocator.hpp>
> #include < xercesc/dom/DOMWriter.hpp>
> #include < xercesc/framework/StdOutFormatTarget.hpp>
> #include < xercesc/framework/LocalFileFormatTarget.hpp>
> #include < xercesc/framework/MemBufInputSource.hpp>
> #include < xercesc/framework/Wrapper4InputSource.hpp>
> #include < xercesc/parsers/XercesDOMParser.hpp>
> #include < xercesc/util/XMLUni.hpp>
> #include < xercesc/util/XMLException.hpp>
> unsigned long getMemUsage ()
> {
>  short gError = 0;
>  short myHandle[10];
>  short attrList[10];
>  short valList[10];
>  short valMaxLen = 10;
>  short valLen = 0;
>  short attrs = 0;
>  unsigned long *memUsage;
>  gError = PROCESSHANDLE_GETMINE_ (&myHandle[0]);
>  if (gError)
>   return 0;35%)
>  memset (&attrList[0], '\0', 10);
>  memset (&valList[0], '\0', 10);
>  attrList[attrs] = 111;
>  attrs++;
>  gError = PROCESS_GETINFOLIST_
>   (,,,,&myHandle[0]
>   ,&attrList[0]
>   ,attrs
>   ,&valList[0]
>   ,valMaxLen
>   ,&valLen
>   );
>  if (gError)
>   return 0;
>  memUsage = (unsigned long *) (&valList[0]);
>  return *memUsage;
> }
> int main()
> {
>  DOMImplementation *impl;
>  DOMBuilder *parser;
>  DOMDocument *doc;
>  const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull };
>  std::cout < < "\nMEMUSAGE at Start : "< < getMemUsage();
>  // Initialize the XML system
>  try {
>         XMLPlatformUtils::Initialize();
>         XMLPlatformUtils::recognizeNEL(false);
>   }
>  catch (const XMLException& toCatch) {
>           return 1;
>  }
>  impl = DOMImplementationRegistry::getDOMImplementation(gLS);
>  parser = ((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0);
>  if (parser == NULL) {
>   //Its known that XML system must be terminated before returning
>   return 1;
>  }
>  parser->setFeature(XMLUni::fgDOMNamespaces,true);
>  parser->setFeature(XMLUni::fgXercesSchema, false);
>  parser->setFeature(XMLUni::fgXercesSchemaFullChecking, false);
>  parser->setFeature(XMLUni::fgDOMValidateIfSchema, false);
>  parser->setFeature(XMLUni::fgDOMDatatypeNormalization, true);
>  //Reset Document Pool
>  parser->resetDocumentPool();
>  std::cout< < "\nMEMUSAGE before parsing: "< < getMemUsage();
>  //Parse XML and get document
>  try{
>   doc = parser->parseURI("personal.xml");
>  }
>  catch(DOMException dome){
>   //Its known that XML system must be terminated before returning
>   return 1;
>  }
>  std::cout< < "\nMEMUSAGE after parsing: "< < getMemUsage();
>  //Reset Document Pool
>  parser->resetDocumentPool();
>  std::cout< < "\nMEMUSAGE after resetDocumentpool(): "< < getMemUsage();
>  //Release Parser
>  //This should also release DOMDOcument associated i.e. doc
>  parser->release();
>  std::cout< < "\nMEMUSAGE after parser release(): "< < getMemUsage();
>  XMLPlatformUtils::Terminate();
>  std::cout< < "\nMEMUSAGE after Terminate(): "< < getMemUsage()< < std::endl;
>  return 0;
> }
> /home/Rinil/xml/dom [2442]:
> 2) Compile using Makefiles provided with XML samples.
> 3) Place a xml file to be parsed in the CWD. ie personal.xml which comes with
> the samples.
> 4) run mleak:
> /home/RinilXml/dom [2452]: ./mleak
> MEMUSAGE at Start : 16384
> MEMUSAGE before parsing: 57344
> MEMUSAGE after parsing: 245888
> MEMUSAGE after resetDocumentpool(): 245888
> MEMUSAGE after parser release(): 245888
> MEMUSAGE after Terminate(): 245888

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@...
For additional commands, e-mail: c-dev-help@...


[jira] Commented: (XERCESC-1589) XML DOM parser does not release memory on parser:release and resetDocumentPool()

by JIRA xerces-c-dev@xml.apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

    [ http://issues.apache.org/jira/browse/XERCESC-1589?page=comments#action_12414482 ]

Alberto Massari commented on XERCESC-1589:
------------------------------------------

Rinil,
the code is almost the same that makes the test MemHandlerTest, that checks for memory leaks (and it finds none).
So, I am inclined to think that either the API PROCESS_GETINFOLIST_ is returning the maximum amount of memory ever allocated by the application, or HP doesn't resize the working set of the application.
In order to test if it's a real leak, try the following actions:
1) check PROCESS_GETINFOLIST_ behavior

std::cout< < "\nMEMUSAGE before malloc: "< < getMemUsage();
void* p=malloc(4*1024*1024);
std::cout< < "\nMEMUSAGE after malloc: "< < getMemUsage();
free(p);
std::cout< < "\nMEMUSAGE after free: "< < getMemUsage();

2) hook a memory monitor in Xerces

    MemoryMonitor *staticMemMonitor = new MemoryMonitor();
    XMLPlatformUtils::Initialize(XMLUni::fgXercescDefaultLocale, 0, 0, staticMemMonitor);

and report its content at the end

    std::cout << "At destruction, staticMemMonitor has " << staticMemMonitor->getTotalMemory() << " bytes.\n";
    delete staticMemMonitor;

(you will need to also copy the code for the MemoryMonitor class)

Hope this helps,
Alberto

> XML DOM parser does not release memory on parser:release and resetDocumentPool()
> --------------------------------------------------------------------------------
>
>          Key: XERCESC-1589
>          URL: http://issues.apache.org/jira/browse/XERCESC-1589
>      Project: Xerces-C++
>         Type: Bug

>   Components: DOM
>     Versions: 2.4.0
>  Environment: HP-Tandem-NonStop Kernel
>     Reporter: Rinil Baxi

>
> 1) Use the following code:
> /home/Rinil/Xml/dom [2441]: more mleak.cpp
> #include < string.h>
> #include < cextdecs.h>
> #include < iostream>
> #include < xercesc/util/PlatformUtils.hpp>
> #include < xercesc/parsers/AbstractDOMParser.hpp>
> #include < xercesc/dom/DOMImplementation.hpp>
> #include < xercesc/dom/DOMImplementationLS.hpp>
> #include < xercesc/dom/DOMImplementationRegistry.hpp>
> #include < xercesc/dom/DOMBuilder.hpp>
> #include < xercesc/dom/DOMException.hpp>
> #include < xercesc/dom/DOMDocument.hpp>
> #include < xercesc/dom/DOMNodeList.hpp>
> #include < xercesc/dom/DOMError.hpp>
> #include < xercesc/dom/DOMLocator.hpp>
> #include < xercesc/dom/DOMWriter.hpp>
> #include < xercesc/framework/StdOutFormatTarget.hpp>
> #include < xercesc/framework/LocalFileFormatTarget.hpp>
> #include < xercesc/framework/MemBufInputSource.hpp>
> #include < xercesc/framework/Wrapper4InputSource.hpp>
> #include < xercesc/parsers/XercesDOMParser.hpp>
> #include < xercesc/util/XMLUni.hpp>
> #include < xercesc/util/XMLException.hpp>
> unsigned long getMemUsage ()
> {
>  short gError = 0;
>  short myHandle[10];
>  short attrList[10];
>  short valList[10];
>  short valMaxLen = 10;
>  short valLen = 0;
>  short attrs = 0;
>  unsigned long *memUsage;
>  gError = PROCESSHANDLE_GETMINE_ (&myHandle[0]);
>  if (gError)
>   return 0;35%)
>  memset (&attrList[0], '\0', 10);
>  memset (&valList[0], '\0', 10);
>  attrList[attrs] = 111;
>  attrs++;
>  gError = PROCESS_GETINFOLIST_
>   (,,,,&myHandle[0]
>   ,&attrList[0]
>   ,attrs
>   ,&valList[0]
>   ,valMaxLen
>   ,&valLen
>   );
>  if (gError)
>   return 0;
>  memUsage = (unsigned long *) (&valList[0]);
>  return *memUsage;
> }
> int main()
> {
>  DOMImplementation *impl;
>  DOMBuilder *parser;
>  DOMDocument *doc;
>  const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull };
>  std::cout < < "\nMEMUSAGE at Start : "< < getMemUsage();
>  // Initialize the XML system
>  try {
>         XMLPlatformUtils::Initialize();
>         XMLPlatformUtils::recognizeNEL(false);
>   }
>  catch (const XMLException& toCatch) {
>           return 1;
>  }
>  impl = DOMImplementationRegistry::getDOMImplementation(gLS);
>  parser = ((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0);
>  if (parser == NULL) {
>   //Its known that XML system must be terminated before returning
>   return 1;
>  }
>  parser->setFeature(XMLUni::fgDOMNamespaces,true);
>  parser->setFeature(XMLUni::fgXercesSchema, false);
>  parser->setFeature(XMLUni::fgXercesSchemaFullChecking, false);
>  parser->setFeature(XMLUni::fgDOMValidateIfSchema, false);
>  parser->setFeature(XMLUni::fgDOMDatatypeNormalization, true);
>  //Reset Document Pool
>  parser->resetDocumentPool();
>  std::cout< < "\nMEMUSAGE before parsing: "< < getMemUsage();
>  //Parse XML and get document
>  try{
>   doc = parser->parseURI("personal.xml");
>  }
>  catch(DOMException dome){
>   //Its known that XML system must be terminated before returning
>   return 1;
>  }
>  std::cout< < "\nMEMUSAGE after parsing: "< < getMemUsage();
>  //Reset Document Pool
>  parser->resetDocumentPool();
>  std::cout< < "\nMEMUSAGE after resetDocumentpool(): "< < getMemUsage();
>  //Release Parser
>  //This should also release DOMDOcument associated i.e. doc
>  parser->release();
>  std::cout< < "\nMEMUSAGE after parser release(): "< < getMemUsage();
>  XMLPlatformUtils::Terminate();
>  std::cout< < "\nMEMUSAGE after Terminate(): "< < getMemUsage()< < std::endl;
>  return 0;
> }
> /home/Rinil/xml/dom [2442]:
> 2) Compile using Makefiles provided with XML samples.
> 3) Place a xml file to be parsed in the CWD. ie personal.xml which comes with
> the samples.
> 4) run mleak:
> /home/RinilXml/dom [2452]: ./mleak
> MEMUSAGE at Start : 16384
> MEMUSAGE before parsing: 57344
> MEMUSAGE after parsing: 245888
> MEMUSAGE after resetDocumentpool(): 245888
> MEMUSAGE after parser release(): 245888
> MEMUSAGE after Terminate(): 245888

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@...
For additional commands, e-mail: c-dev-help@...


[jira] Commented: (XERCESC-1589) XML DOM parser does not release memory on parser:release and resetDocumentPool()

by JIRA xerces-c-dev@xml.apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

    [ http://issues.apache.org/jira/browse/XERCESC-1589?page=comments#action_12414565 ]

Rinil Baxi commented on XERCESC-1589:
-------------------------------------

Alberto,

Thanks for the analysis and reply.
Even I have gone through the code and check this scenario completely.
I have designed one simple test case with malloc and free; and also with new and delete.
It shows that when I call free/delete, my object releases memory; but my process still owning this free chunk and this chunk is available for next allocation within that application.
So I conclude that this is not the problem of memory leak or memory usage but the problem with free and delete design. It has nothing to do with XML Parser.

Here I am attaching the sample test program and also its output.

------ Memtest.hpp ------------------

#include <iostream>
#include <string>

class memTest
{
  private:
        int* i;
        char* ch;

  public:
        memTest();
        ~memTest();
        void MyPrint();
};

// Constructor
memTest::memTest()
{
        i = new int[100000];
        ch = (char*)malloc(100000);
}

// Destructor
memTest::~memTest()
{
        delete[] i;
        free(ch);
}

// Print Function - Dummy method of the class
void memTest::MyPrint()
{
        for (int j=0;j<100000;j++)
             i[j]=j;
        for (int j=0;j<100000;j++)
             ch[j]='A';
}
------------ test.cpp ------------------------
#include <cextdecs.h (PROCESS_GETINFOLIST_, PROCESSHANDLE_GETMINE_)>
#include "memTest.hpp" // Test class
#include <stdlib.h>
using namespace std;

// Shows current heap usage of the process
unsigned long getMemUsage ()
{
        short gError = 0;
        short myHandle[10];
        short attrList[10];
        short valList[10];
        short valMaxLen = 10;
        short valLen = 0;
        short attrs = 0;
        unsigned long *memUsage;

        gError = PROCESSHANDLE_GETMINE_ (&myHandle[0]);

        if (gError)
             return 0;

        memset (&attrList[0], '\0', 10);
        memset (&valList[0], '\0', 10);
        attrList[attrs] = 111;
        attrs++;

        gError = PROCESS_GETINFOLIST_
             (,,,,&myHandle[0]
              ,&attrList[0]
              ,attrs
              ,&valList[0]
              ,valMaxLen
              ,&valLen
             );

        if (gError)
             return 0;

        memUsage = (unsigned long *) (&valList[0]);
        return *memUsage;
}

int main()
{
        int iterations=5;

        std::cout << "\nMEMUSAGE at Start : "<< getMemUsage();

        for (int i = 1; i < iterations; i++)
        {
             memTest* newObject = new memTest();
             std::cout<< "\n\nIteration NO : " <<i;
             std::cout<< "\n--------- --  ";
             std::cout<< "\nMEMUSAGE after creation of object: "<< getMemUsage();
             newObject->MyPrint();
             delete newObject;
             std::cout<< "\nMEMUSAGE after deletion of object: "<< getMemUsage();
        }
        std::cout<<"\n";
        return 0;
}

------------------ output ---------------------------------

MEMUSAGE at Start : 24576

Iteration NO : 1
--------- --
MEMUSAGE after creation of object: 524592
MEMUSAGE after deletion of object: 524592

Iteration NO : 2
--------- --
MEMUSAGE after creation of object: 524592
MEMUSAGE after deletion of object: 524592

Iteration NO : 3
--------- --
MEMUSAGE after creation of object: 524592
MEMUSAGE after deletion of object: 524592

Iteration NO : 4
--------- --
MEMUSAGE after creation of object: 524592
MEMUSAGE after deletion of object: 524592

-------------------------------------------------------------------------------------

I got this results on HP Tandem NSK.
I dont know the behaviour of free and delete on other operating systems.

I dont have systems with solaris or linux platforms.
Could  you please confirm, if feasible, whether similar behaviour is observerd on Solaris and Linux platform also.

Thanks in advance.

Best Regards,
Rinil

> XML DOM parser does not release memory on parser:release and resetDocumentPool()
> --------------------------------------------------------------------------------
>
>          Key: XERCESC-1589
>          URL: http://issues.apache.org/jira/browse/XERCESC-1589
>      Project: Xerces-C++
>         Type: Bug

>   Components: DOM
>     Versions: 2.4.0
>  Environment: HP-Tandem-NonStop Kernel
>     Reporter: Rinil Baxi

>
> 1) Use the following code:
> /home/Rinil/Xml/dom [2441]: more mleak.cpp
> #include < string.h>
> #include < cextdecs.h>
> #include < iostream>
> #include < xercesc/util/PlatformUtils.hpp>
> #include < xercesc/parsers/AbstractDOMParser.hpp>
> #include < xercesc/dom/DOMImplementation.hpp>
> #include < xercesc/dom/DOMImplementationLS.hpp>
> #include < xercesc/dom/DOMImplementationRegistry.hpp>
> #include < xercesc/dom/DOMBuilder.hpp>
> #include < xercesc/dom/DOMException.hpp>
> #include < xercesc/dom/DOMDocument.hpp>
> #include < xercesc/dom/DOMNodeList.hpp>
> #include < xercesc/dom/DOMError.hpp>
> #include < xercesc/dom/DOMLocator.hpp>
> #include < xercesc/dom/DOMWriter.hpp>
> #include < xercesc/framework/StdOutFormatTarget.hpp>
> #include < xercesc/framework/LocalFileFormatTarget.hpp>
> #include < xercesc/framework/MemBufInputSource.hpp>
> #include < xercesc/framework/Wrapper4InputSource.hpp>
> #include < xercesc/parsers/XercesDOMParser.hpp>
> #include < xercesc/util/XMLUni.hpp>
> #include < xercesc/util/XMLException.hpp>
> unsigned long getMemUsage ()
> {
>  short gError = 0;
>  short myHandle[10];
>  short attrList[10];
>  short valList[10];
>  short valMaxLen = 10;
>  short valLen = 0;
>  short attrs = 0;
>  unsigned long *memUsage;
>  gError = PROCESSHANDLE_GETMINE_ (&myHandle[0]);
>  if (gError)
>   return 0;35%)
>  memset (&attrList[0], '\0', 10);
>  memset (&valList[0], '\0', 10);
>  attrList[attrs] = 111;
>  attrs++;
>  gError = PROCESS_GETINFOLIST_
>   (,,,,&myHandle[0]
>   ,&attrList[0]
>   ,attrs
>   ,&valList[0]
>   ,valMaxLen
>   ,&valLen
>   );
>  if (gError)
>   return 0;
>  memUsage = (unsigned long *) (&valList[0]);
>  return *memUsage;
> }
> int main()
> {
>  DOMImplementation *impl;
>  DOMBuilder *parser;
>  DOMDocument *doc;
>  const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull };
>  std::cout < < "\nMEMUSAGE at Start : "< < getMemUsage();
>  // Initialize the XML system
>  try {
>         XMLPlatformUtils::Initialize();
>         XMLPlatformUtils::recognizeNEL(false);
>   }
>  catch (const XMLException& toCatch) {
>           return 1;
>  }
>  impl = DOMImplementationRegistry::getDOMImplementation(gLS);
>  parser = ((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0);
>  if (parser == NULL) {
>   //Its known that XML system must be terminated before returning
>   return 1;
>  }
>  parser->setFeature(XMLUni::fgDOMNamespaces,true);
>  parser->setFeature(XMLUni::fgXercesSchema, false);
>  parser->setFeature(XMLUni::fgXercesSchemaFullChecking, false);
>  parser->setFeature(XMLUni::fgDOMValidateIfSchema, false);
>  parser->setFeature(XMLUni::fgDOMDatatypeNormalization, true);
>  //Reset Document Pool
>  parser->resetDocumentPool();
>  std::cout< < "\nMEMUSAGE before parsing: "< < getMemUsage();
>  //Parse XML and get document
>  try{
>   doc = parser->parseURI("personal.xml");
>  }
>  catch(DOMException dome){
>   //Its known that XML system must be terminated before returning
>   return 1;
>  }
>  std::cout< < "\nMEMUSAGE after parsing: "< < getMemUsage();
>  //Reset Document Pool
>  parser->resetDocumentPool();
>  std::cout< < "\nMEMUSAGE after resetDocumentpool(): "< < getMemUsage();
>  //Release Parser
>  //This should also release DOMDOcument associated i.e. doc
>  parser->release();
>  std::cout< < "\nMEMUSAGE after parser release(): "< < getMemUsage();
>  XMLPlatformUtils::Terminate();
>  std::cout< < "\nMEMUSAGE after Terminate(): "< < getMemUsage()< < std::endl;
>  return 0;
> }
> /home/Rinil/xml/dom [2442]:
> 2) Compile using Makefiles provided with XML samples.
> 3) Place a xml file to be parsed in the CWD. ie personal.xml which comes with
> the samples.
> 4) run mleak:
> /home/RinilXml/dom [2452]: ./mleak
> MEMUSAGE at Start : 16384
> MEMUSAGE before parsing: 57344
> MEMUSAGE after parsing: 245888
> MEMUSAGE after resetDocumentpool(): 245888
> MEMUSAGE after parser release(): 245888
> MEMUSAGE after Terminate(): 245888

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@...
For additional commands, e-mail: c-dev-help@...


[jira] Resolved: (XERCESC-1589) XML DOM parser does not release memory on parser:release and resetDocumentPool()

by JIRA xerces-c-dev@xml.apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

     [ http://issues.apache.org/jira/browse/XERCESC-1589?page=all ]
     
Alberto Massari resolved XERCESC-1589:
--------------------------------------

    Resolution: Invalid

Hi Rinil,
I never saw such behaviour, so it's either a feature of the API you are using (i.e. it returns the maximum value of memory allocated) or a feature of the C runtime you are using (it never releases the memory it allocates, but it keeps it for the next allocations).
Having said that, it's not a bug in Xerces, but a feature of the platform you are working on.

Alberto

> XML DOM parser does not release memory on parser:release and resetDocumentPool()
> --------------------------------------------------------------------------------
>
>          Key: XERCESC-1589
>          URL: http://issues.apache.org/jira/browse/XERCESC-1589
>      Project: Xerces-C++
>         Type: Bug

>   Components: DOM
>     Versions: 2.4.0
>  Environment: HP-Tandem-NonStop Kernel
>     Reporter: Rinil Baxi

>
> 1) Use the following code:
> /home/Rinil/Xml/dom [2441]: more mleak.cpp
> #include < string.h>
> #include < cextdecs.h>
> #include < iostream>
> #include < xercesc/util/PlatformUtils.hpp>
> #include < xercesc/parsers/AbstractDOMParser.hpp>
> #include < xercesc/dom/DOMImplementation.hpp>
> #include < xercesc/dom/DOMImplementationLS.hpp>
> #include < xercesc/dom/DOMImplementationRegistry.hpp>
> #include < xercesc/dom/DOMBuilder.hpp>
> #include < xercesc/dom/DOMException.hpp>
> #include < xercesc/dom/DOMDocument.hpp>
> #include < xercesc/dom/DOMNodeList.hpp>
> #include < xercesc/dom/DOMError.hpp>
> #include < xercesc/dom/DOMLocator.hpp>
> #include < xercesc/dom/DOMWriter.hpp>
> #include < xercesc/framework/StdOutFormatTarget.hpp>
> #include < xercesc/framework/LocalFileFormatTarget.hpp>
> #include < xercesc/framework/MemBufInputSource.hpp>
> #include < xercesc/framework/Wrapper4InputSource.hpp>
> #include < xercesc/parsers/XercesDOMParser.hpp>
> #include < xercesc/util/XMLUni.hpp>
> #include < xercesc/util/XMLException.hpp>
> unsigned long getMemUsage ()
> {
>  short gError = 0;
>  short myHandle[10];
>  short attrList[10];
>  short valList[10];
>  short valMaxLen = 10;
>  short valLen = 0;
>  short attrs = 0;
>  unsigned long *memUsage;
>  gError = PROCESSHANDLE_GETMINE_ (&myHandle[0]);
>  if (gError)
>   return 0;35%)
>  memset (&attrList[0], '\0', 10);
>  memset (&valList[0], '\0', 10);
>  attrList[attrs] = 111;
>  attrs++;
>  gError = PROCESS_GETINFOLIST_
>   (,,,,&myHandle[0]
>   ,&attrList[0]
>   ,attrs
>   ,&valList[0]
>   ,valMaxLen
>   ,&valLen
>   );
>  if (gError)
>   return 0;
>  memUsage = (unsigned long *) (&valList[0]);
>  return *memUsage;
> }
> int main()
> {
>  DOMImplementation *impl;
>  DOMBuilder *parser;
>  DOMDocument *doc;
>  const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull };
>  std::cout < < "\nMEMUSAGE at Start : "< < getMemUsage();
>  // Initialize the XML system
>  try {
>         XMLPlatformUtils::Initialize();
>         XMLPlatformUtils::recognizeNEL(false);
>   }
>  catch (const XMLException& toCatch) {
>           return 1;
>  }
>  impl = DOMImplementationRegistry::getDOMImplementation(gLS);
>  parser = ((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0);
>  if (parser == NULL) {
>   //Its known that XML system must be terminated before returning
>   return 1;
>  }
>  parser->setFeature(XMLUni::fgDOMNamespaces,true);
>  parser->setFeature(XMLUni::fgXercesSchema, false);
>  parser->setFeature(XMLUni::fgXercesSchemaFullChecking, false);
>  parser->setFeature(XMLUni::fgDOMValidateIfSchema, false);
>  parser->setFeature(XMLUni::fgDOMDatatypeNormalization, true);
>  //Reset Document Pool
>  parser->resetDocumentPool();
>  std::cout< < "\nMEMUSAGE before parsing: "< < getMemUsage();
>  //Parse XML and get document
>  try{
>   doc = parser->parseURI("personal.xml");
>  }
>  catch(DOMException dome){
>   //Its known that XML system must be terminated before returning
>   return 1;
>  }
>  std::cout< < "\nMEMUSAGE after parsing: "< < getMemUsage();
>  //Reset Document Pool
>  parser->resetDocumentPool();
>  std::cout< < "\nMEMUSAGE after resetDocumentpool(): "< < getMemUsage();
>  //Release Parser
>  //This should also release DOMDOcument associated i.e. doc
>  parser->release();
>  std::cout< < "\nMEMUSAGE after parser release(): "< < getMemUsage();
>  XMLPlatformUtils::Terminate();
>  std::cout< < "\nMEMUSAGE after Terminate(): "< < getMemUsage()< < std::endl;
>  return 0;
> }
> /home/Rinil/xml/dom [2442]:
> 2) Compile using Makefiles provided with XML samples.
> 3) Place a xml file to be parsed in the CWD. ie personal.xml which comes with
> the samples.
> 4) run mleak:
> /home/RinilXml/dom [2452]: ./mleak
> MEMUSAGE at Start : 16384
> MEMUSAGE before parsing: 57344
> MEMUSAGE after parsing: 245888
> MEMUSAGE after resetDocumentpool(): 245888
> MEMUSAGE after parser release(): 245888
> MEMUSAGE after Terminate(): 245888

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@...
For additional commands, e-mail: c-dev-help@...


[jira] Commented: (XERCESC-1589) XML DOM parser does not release memory on parser:release and resetDocumentPool()

by JIRA xerces-c-dev@xml.apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

    [ http://issues.apache.org/jira/browse/XERCESC-1589?page=comments#action_12414688 ]

Rinil Baxi commented on XERCESC-1589:
-------------------------------------

Hi Alberto,

I have cinfirmed that this the feature of C runtime that we are using on Tandem platform.
This is not the bug with xercesc parser.

Many thanks for your detailed analysis and reply.

Best Regards,
Rinil

> XML DOM parser does not release memory on parser:release and resetDocumentPool()
> --------------------------------------------------------------------------------
>
>          Key: XERCESC-1589
>          URL: http://issues.apache.org/jira/browse/XERCESC-1589
>      Project: Xerces-C++
>         Type: Bug

>   Components: DOM
>     Versions: 2.4.0
>  Environment: HP-Tandem-NonStop Kernel
>     Reporter: Rinil Baxi

>
> 1) Use the following code:
> /home/Rinil/Xml/dom [2441]: more mleak.cpp
> #include < string.h>
> #include < cextdecs.h>
> #include < iostream>
> #include < xercesc/util/PlatformUtils.hpp>
> #include < xercesc/parsers/AbstractDOMParser.hpp>
> #include < xercesc/dom/DOMImplementation.hpp>
> #include < xercesc/dom/DOMImplementationLS.hpp>
> #include < xercesc/dom/DOMImplementationRegistry.hpp>
> #include < xercesc/dom/DOMBuilder.hpp>
> #include < xercesc/dom/DOMException.hpp>
> #include < xercesc/dom/DOMDocument.hpp>
> #include < xercesc/dom/DOMNodeList.hpp>
> #include < xercesc/dom/DOMError.hpp>
> #include < xercesc/dom/DOMLocator.hpp>
> #include < xercesc/dom/DOMWriter.hpp>
> #include < xercesc/framework/StdOutFormatTarget.hpp>
> #include < xercesc/framework/LocalFileFormatTarget.hpp>
> #include < xercesc/framework/MemBufInputSource.hpp>
> #include < xercesc/framework/Wrapper4InputSource.hpp>
> #include < xercesc/parsers/XercesDOMParser.hpp>
> #include < xercesc/util/XMLUni.hpp>
> #include < xercesc/util/XMLException.hpp>
> unsigned long getMemUsage ()
> {
>  short gError = 0;
>  short myHandle[10];
>  short attrList[10];
>  short valList[10];
>  short valMaxLen = 10;
>  short valLen = 0;
>  short attrs = 0;
>  unsigned long *memUsage;
>  gError = PROCESSHANDLE_GETMINE_ (&myHandle[0]);
>  if (gError)
>   return 0;35%)
>  memset (&attrList[0], '\0', 10);
>  memset (&valList[0], '\0', 10);
>  attrList[attrs] = 111;
>  attrs++;
>  gError = PROCESS_GETINFOLIST_
>   (,,,,&myHandle[0]
>   ,&attrList[0]
>   ,attrs
>   ,&valList[0]
>   ,valMaxLen
>   ,&valLen
>   );
>  if (gError)
>   return 0;
>  memUsage = (unsigned long *) (&valList[0]);
>  return *memUsage;
> }
> int main()
> {
>  DOMImplementation *impl;
>  DOMBuilder *parser;
>  DOMDocument *doc;
>  const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull };
>  std::cout < < "\nMEMUSAGE at Start : "< < getMemUsage();
>  // Initialize the XML system
>  try {
>         XMLPlatformUtils::Initialize();
>         XMLPlatformUtils::recognizeNEL(false);
>   }
>  catch (const XMLException& toCatch) {
>           return 1;
>  }
>  impl = DOMImplementationRegistry::getDOMImplementation(gLS);
>  parser = ((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0);
>  if (parser == NULL) {
>   //Its known that XML system must be terminated before returning
>   return 1;
>  }
>  parser->setFeature(XMLUni::fgDOMNamespaces,true);
>  parser->setFeature(XMLUni::fgXercesSchema, false);
>  parser->setFeature(XMLUni::fgXercesSchemaFullChecking, false);
>  parser->setFeature(XMLUni::fgDOMValidateIfSchema, false);
>  parser->setFeature(XMLUni::fgDOMDatatypeNormalization, true);
>  //Reset Document Pool
>  parser->resetDocumentPool();
>  std::cout< < "\nMEMUSAGE before parsing: "< < getMemUsage();
>  //Parse XML and get document
>  try{
>   doc = parser->parseURI("personal.xml");
>  }
>  catch(DOMException dome){
>   //Its known that XML system must be terminated before returning
>   return 1;
>  }
>  std::cout< < "\nMEMUSAGE after parsing: "< < getMemUsage();
>  //Reset Document Pool
>  parser->resetDocumentPool();
>  std::cout< < "\nMEMUSAGE after resetDocumentpool(): "< < getMemUsage();
>  //Release Parser
>  //This should also release DOMDOcument associated i.e. doc
>  parser->release();
>  std::cout< < "\nMEMUSAGE afte