BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Variant memory leaks with Widestrings.

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++)
View previous topic :: View next topic  
Author Message
Roddy Pratt
Guest





PostPosted: Tue Dec 12, 2006 5:58 pm    Post subject: Variant memory leaks with Widestrings. Reply with quote



Not sure if this should be here or the RTL group:-

I've been tracking down some horrendous long-term resource/memory leaks
when using BDS2006's TXMLDocument, and have traced most of them to two
routines in variants.cpp:-

__fastcall Variant::Variant(const WideString& src)
{
SetType(varOleStr, true);
(WideString&)VOleStr = src.Copy(); // this line leaks! should be:
"(WideString&)VOleStr = src;"
}

__fastcall Variant::operator WideString() const
{
Variant tmp;
Varhlpr::VariantCast(*this, tmp, varOleStr);
#if defined(WIDESTRING_IS_BSTR)
return WideString::Copy(tmp.VOleStr); // this line leaks! should be
"return tmp.VOleStr;"
#else
return tmp.VOleStr;
#endif
}

My 'fixes' are shown in the comments - the problem is that the
".Copy()" method creates a temporary, which is not needed because the
assignment operator generates a fresh copy anyway. So the 'fixed'
versions are faster as well.

Anyone have any comments on these? There may be other leaks I haven't
found yet...

- Roddy
Back to top
Roddy Pratt
Guest





PostPosted: Tue Dec 12, 2006 7:28 pm    Post subject: Re: Variant memory leaks with Widestrings. Reply with quote



Darko Miletic wrote:

Quote:
This looks like a nice new report for QC.

Well, there's one already there. This is caused (and fixed) by the
Variant Widestring constructor, even though the problem shows here with
OLEVariants and char* arrays...

http://qc.borland.com/wc/qcmain.aspx?d=31712


- Roddy
--
Back to top
Darko Miletic
Guest





PostPosted: Tue Dec 12, 2006 7:29 pm    Post subject: Re: Variant memory leaks with Widestrings. Reply with quote



Roddy Pratt wrote:
Quote:
Not sure if this should be here or the RTL group:-

Anyone have any comments on these? There may be other leaks I haven't
found yet...

This looks like a nice new report for QC.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.