 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Roddy Pratt Guest
|
Posted: Tue Dec 12, 2006 5:58 pm Post subject: Variant memory leaks with Widestrings. |
|
|
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
|
Posted: Tue Dec 12, 2006 7:28 pm Post subject: Re: Variant memory leaks with Widestrings. |
|
|
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
|
Posted: Tue Dec 12, 2006 7:29 pm Post subject: Re: Variant memory leaks with Widestrings. |
|
|
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 |
|
 |
|
|
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
|
|