memory address leak when running many threads which will parsing xml files
--------------------------------------------------------------------------

                 Key: XERCESC-1901
                 URL: https://issues.apache.org/jira/browse/XERCESC-1901
             Project: Xerces-C++
          Issue Type: Bug
          Components: SAX/SAX2
    Affects Versions: 3.0.1
         Environment: Red Hat Enterprise Linux Server release 5.1 (Tikanga)
-g++ --version  : x86_64-redhat-linux-g++ (GCC) 4.1.1 20070105 (Red Hat 
4.1.1-52)
            Reporter: tao xiaochuan


when running 5 threads , in each thread a xml file will (for test purpost 
xerces-c-3.0.1\samples\data\long.xml is used)
be parsed, it is found, by top command , VIRT increase large , by pmap command 
,  3 (some time 4) memory address block about 64 m
are found  , when by 8 threads  , there will be 5 (some time 6) such blocks :
Address           Kbytes Mode  Offset           Device    Mapping
00002aaab00b9000   64796 ----- 00002aaab00b9000 000:00000   [ anon ]
...
00002aaab40b9000   64796 ----- 00002aaab40b9000 000:00000   [ anon ]
...
00002aaab80bb000   64788 ----- 00002aaab80bb000 000:00000   [ anon ]


these blocks will not be released even after XMLPlatformUtils::Terminate();
if there is only one thead , there is no such a problem

chief code structure:
main(){
   XMLPlatformUtils::Initialize();
   //start many threads
   //wait for alll threads ends
   XMLPlatformUtils::Terminate();    
}
in each thread :
while(true){   
    ...            
      
    auto_ptr<SAXParser> parser( new SAXParser() );
    parser->setDocumentHandler(this);     //the handler do nothing but just 
extend from HandlerBase
    parser->setErrorHandler(this);        //the handler do nothing but just 
extend from HandlerBase
    parser->setValidationScheme(SAXParser::Val_Never);
    parser->setDoSchema(false);
    parser->setDoNamespaces(true);
    parser->parse(inputFile.c_str());        
    
}
refer to attachment  for detail about the simple test code

one more related question :

in the doc , it is said "client application needs to Terminate() (or multiple 
Terminate() in the case where multiple Initialize() have been invoked before" , 
does it also suit for more than one threads ?

for example  :
 thread 1 :  XMLPlatformUtils::Initialize();   //A
 thread 1 :  do some parsing                   //B
 thread 2 :  XMLPlatformUtils::Initialize();   //C
 thread 2 :  do some parsing                   //D
 thread 1 :  do some parsing                   //E
 thread 1 :  XMLPlatformUtils::Terminate();    //F
 thread 2 :  do some parsing                   //G
 thread 1 :  XMLPlatformUtils::Terminate();    //H
}
since these two api are all static , then does C will affect E and does F 
affect G

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to