OK Got the problem
I was not calling XMLPlatformUtils::Terminate(); at the end of my program.
The misleading error of memory caused the confusion.
Now the Purifier does not show any leak.

Thanks


Alberto Massari wrote:
> 
> You don't say how the macro X() is implemented; also, beware that you 
> are putting in "len" the ASCII length of the string, and that could be 
> different from the the UTF-16 length.
> The correct code would involve two transcoders, one from the encoding 
> you know is used for the "buffer" variable to Unicode, and one from 
> Unicode to UTF-8.
> 
> Alberto
> 
> plele wrote:
>> I am using xerces 2.8 in C++ API
>> I created a function to convert to UTF8
>>
>> void convertToUTF8(const char* buffer, string &utf8_string)
>> {
>>         XMLTranscoder* utf8Transcoder; 
>>         XMLTransService::Codes failReason; 
>>         utf8Transcoder =
>> XMLPlatformUtils::fgTransService->makeNewTranscoderFor("UTF-8",
>> failReason,
>> 16*1024); 
>>         size_t len = XMLString::stringLen(buffer); 
>>         XMLByte* utf8 = new XMLByte[(len*MB_LEN_MAX)+1]; 
>>         unsigned int eaten; 
>>         unsigned int utf8Len = utf8Transcoder->transcodeTo(X(buffer),
>> len,
>> utf8, len*MB_LEN_MAX, eaten, XMLTranscoder::UnRep_Throw); 
>>         utf8[utf8Len] = '\0'; 
>>         utf8_string = (char*)utf8; 
>>         delete[] utf8;
>>         delete utf8Transcoder;
>> }
>>
>> But this function leaks memory when I pass it through the Purify tool to
>> detect memory leaks.
>>
>> [I] MPK: Potential memory leak of 4164 bytes from 214 blocks allocated in
>> xercesc_2_8::MemoryManagerImpl::allocate(UINT) [XERCES-C_2_8D.DLL]
>>         Offset 0x00000008 referenced by 0x122cfd54, a location in a
>> section
>> in a loaded module
>>         Distribution of potentially leaked blocks
>>         Allocation location
>>             new(UINT)     
>> [f:\sp\vctools\crt_bld\self_x86\crt\src\new.cpp:57]
>>             xercesc_2_8::MemoryManagerImpl::allocate(UINT)
>> [F:\WORKDIR\MYPARSER\DEBUG\XERCES-C_2_8D.DLL]
>>
>>
>> Is there something I need to do explicity to release the memory?
>> Please let me know.
>>
>> Thanks
>> PL
>>
>>   
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/memory-leak-using-XMLTranscoder-tp26314147p26315067.html
Sent from the Xerces - C - Dev mailing list archive at Nabble.com.


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

Reply via email to