[EMAIL PROTECTED] wrote:
Dear Sir :
I use xerces for parsing XML String , I found some
question in my test
platform : IBM AIX 5.2
complier : IBM VA C++
xerces version : 2-8-0
Q1. xerces can support multi-thread ? ( I found answer in
xerces faq from http://xerces.apache.org/xerces-c/faq-parse-3.html#faq-6 )
need you double confirm
Why do you need confirmation? If you follow the instructions in the
FAQ, you should not have any problems with using Xerces-C in a
multi-threaded application.
Q2. In my function , always core dump in ( new
MemBufInputSource )
OK, please show us the stack trace for the dump.
I use C++ while function for test xerces have memory
leak
I'm afraid I don't understand what you're saying.
Q3. If I use C++ delete function delete xerces object ,
why xerces still have memory leak ?
Perhaps the leak is in your code and not in Xerces-C?
Q4. MemBufInputSource have limit usage ?
I'm not sure what you mean by "limit usage." As long as you use the
class correctly, it should work as designed.
attach file is my function
Source Code
=========================================================================================
try
{
XMLPlatformUtils::Initialize();
PPT_METHODTRACE_V1( "" , "================== Now Starting Parse XML
==================" ) ;
string XMLString = (const char * )xmlContextInfoSeq[i].xmlContext ;
I'm not sure why this cast is necessary. What is the type of
xmlContextInfoSeq[i]xmlContext?
string parseString = "";
PPT_METHODTRACE_V2( "" , " XMLString :" , XMLString.c_str() );
string bufferId = "prodInfo" ;
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager;
MemoryManager* const manager2 = XMLPlatformUtils::fgMemoryManager;
MemBufInputSource* memBufIS = new MemBufInputSource ((const
XMLByte*)XMLString.c_str(),
strlen(XMLString.c_str()),
Why not use XMLString.length() here?
bufferId.c_str(),
false,
manager2
);
DOMInputSource * inSource = new Wrapper4InputSource(memBufIS,true,
manager);
You have indicated to Wrapper4InputSource that it owns the object
pointed to by "memBufIS," so it will delete the instance in its destructor.
DOMImplementation *impl =
DOMImplementationRegistry::getDOMImplementation(X(""));
DOMBuilder* parser = ((DOMImplementationLS*)impl)->
createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0);
DOMDocument* xmlDoc;
xmlDoc = parser->parse(*inSource);
DOMElement * root = xmlDoc->getDocumentElement();
DOMNodeList * list = xmlDoc->getElementsByTagName(X("ObjInfo"));
//=============================//
// XMLSize_t Use Size_t //
// default start from value 0 //
//=============================//
for ( XMLSize_t index_Attr = 0 ; index_Attr < list->getLength() ;
index_Attr++ )
{
DOMElement * elem =
static_cast<DOMElement*>(list->item(index_Attr)) ;
string lot_id = "" ;
string eqp_id = "" ;
string value = "" ;
objectIdentifier mem_control ;
const XMLCh * tmpxmlch = elem->getAttribute(X("ObjType"));
mem_control.identifier = XMLString::transcode(tmpxmlch);
You need to call XMLString::release() on the pointer returned by
XMLString::transcode(). I don't know what the type of
mem_control.identifier is, but this could be a leak.
value = (const char *)mem_control.identifier ;
Why do you need this cast?
PPT_METHODTRACE_V2( "" , " Objtype value :" , value.c_str() );
if ( value == "Equipment" )
{
objectIdentifier mem_control2 ;
const XMLCh * tmpxmlch2 = elem->getAttribute(X("Value"));
mem_control2.identifier = XMLString::transcode(tmpxmlch2);
Again, this may be a leak.
eqp_id = (const char *)mem_control2.identifier;
Again, why do you need this cast?
PPT_METHODTRACE_V2( "" , " eqp_id :" , eqp_id.c_str() );
setIDLstring(strObjXMLparse_out.strXMLvalueSeq[i].eqpID ,
eqp_id ) ;
PPT_METHODTRACE_V2( "" , "
strObjXMLparse_out.strXMLvalueSeq[i].eqpID " ,
strObjXMLparse_out.strXMLvalueSeq[i].eqpID );
}
else if ( value == "Lot" )
{
objectIdentifier mem_control3 ;
const XMLCh * tmpxmlch3 = elem->getAttribute(X("Value")) ;
mem_control3.identifier = XMLString::transcode(tmpxmlch3);
Perhaps another leak.
lot_id = (const char *)mem_control3.identifier ;
Another strange cast.
PPT_METHODTRACE_V2( "" , " lot_id :" , lot_id.c_str() );
setIDLstring(strObjXMLparse_out.strXMLvalueSeq[i].lotID,lot_id)
;
PPT_METHODTRACE_V2( "" , "
strObjXMLparse_out.strXMLvalueSeq[i].lotID " ,
strObjXMLparse_out.strXMLvalueSeq[i].lotID );
}
}
delete inSource ;
delete parser ;
}
catch (const XMLException& toCatch)
{
char* message = XMLString::transcode(toCatch.getMessage());
PPT_METHODTRACE_V2( "" , "Error during initialization :" , message );
XMLString::release(&message);
return 1;
If you return from this path, you will leave the library initialized.
Since you have no other catch handlers, this could be an exception
that's not from the XMLPlatformUtils::Initialize() call.
}
XMLPlatformUtils::Terminate();
PPT_METHODTRACE_V1( "" , "================== Now Ending Parse XML
==================" ) ;
Best Regards, Sincerely
---------------------------------------------------------------------------
TSMC PROPERTY
This email communication (and any attachments) is proprietary information
for the sole use of its
intended recipient. Any unauthorized review, use or distribution by anyone
other than the intended
recipient is strictly prohibited. If you are not the intended recipient,
please notify the sender by
replying to this email, and then delete this email and any copies of it
immediately. Thank you.
---------------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]