You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Williamson, Siehnai" <sw...@docucorp.com> on 2001/10/17 23:38:22 UTC
Memory leak
Hi Everyone,
There appears to be a memory leak in the SAX parser during validation. It
occurs at the line XMLMutex* tmpMutex = new XMLMutex in the
gVAlidatorMutex() method of the XMLValidator class (see below):
*****
static XMLMutex& gValidatorMutex()
{
static XMLMutex* validatorMutex = 0;
if (!validatorMutex)
{
XMLMutex* tmpMutex = new XMLMutex;
if (XMLPlatformUtils::compareAndSwap((void**)&validatorMutex,
tmpMutex, 0))
{
// Someone beat us to it, so let's clean up ours
delete tmpMutex;
}
}
return *validatorMutex;
}
*****
tmpMutex appears to never have been deleted if
XMLPlatformUtils::compareAndSwap((void**)&validatorMutex, tmpMutex, 0)
returns 0. If it is deleted by XMLPlatformUtils, I don't see it. Please
help.
Siehnai Williamson
DocuCorp International, Inc.
Tel: (214) 891-6401
Re: Memory leak
Posted by PeiYong Zhang <pe...@ca.ibm.com>.
Williamson,
Yes, that tmpMutex shall be registered so that
XMLPlatformUtil::terminate() can release it.
Would you please report the bug to bugzilla so that its status can
be traced, thanks.
Rgds,
PeiYong
"Williamson, Siehnai" wrote:
>
>
> Hi Everyone,
>
> There appears to be a memory leak in the SAX parser during
> validation. It occurs at the line XMLMutex* tmpMutex = new XMLMutex
> in the gVAlidatorMutex() method of the XMLValidator class (see below):
>
> *****
>
> static XMLMutex& gValidatorMutex()
> {
> static XMLMutex* validatorMutex = 0;
> if (!validatorMutex)
> {
> XMLMutex* tmpMutex = new XMLMutex;
> if (XMLPlatformUtils::compareAndSwap((void**)&validatorMutex,
> tmpMutex, 0))
> {
> // Someone beat us to it, so let's clean up ours
> delete tmpMutex;
> }
> }
> return *validatorMutex;
> }
>
> *****
>
> tmpMutex appears to never have been deleted if
> XMLPlatformUtils::compareAndSwap((void**)&validatorMutex, tmpMutex, 0)
> returns 0. If it is deleted by XMLPlatformUtils, I don't see it.
> Please help.
>
>
> Siehnai Williamson
> DocuCorp International, Inc.
> Tel: (214) 891-6401
RE: Memory leak
Posted by Erik Rydgren <er...@mandarinen.se>.
Of course the return values is compleatly the opposite of what I just
said... :D
Erik
-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se]
Sent: den 18 oktober 2001 13:32
To: xerces-c-dev@xml.apache.org
Subject: RE: Memory leak
Hi!
My memory checking tool also reported this but it is actually correct.
The compareAndSwap just does an atomic assignment to a pointer.
So if validatorMutex is 0 it will get the value of tmpMutex and the fuction
returns true.
Or if validatorMutex already was set the function leaves it and returns
false.
Although the validatorMutex is never deleted, however my application doesn't
have any problems with that so I didn't dig any deaper. Xerces leaks ONE
instance of XMLMutex in total. It will not leak one for each Parse.
Regards
Erik Rydgren
Mandarinen systems AB
Seden
-----Original Message-----
From: Williamson, Siehnai [mailto:swilliamson@docucorp.com]
Sent: den 17 oktober 2001 23:38
To: 'xerces-c-dev@xml.apache.org'
Subject: Memory leak
Hi Everyone,
There appears to be a memory leak in the SAX parser during validation. It
occurs at the line XMLMutex* tmpMutex = new XMLMutex in the
gVAlidatorMutex() method of the XMLValidator class (see below):
*****
static XMLMutex& gValidatorMutex()
{
static XMLMutex* validatorMutex = 0;
if (!validatorMutex)
{
XMLMutex* tmpMutex = new XMLMutex;
if (XMLPlatformUtils::compareAndSwap((void**)&validatorMutex,
tmpMutex, 0))
{
// Someone beat us to it, so let's clean up ours
delete tmpMutex;
}
}
return *validatorMutex;
}
*****
tmpMutex appears to never have been deleted if
XMLPlatformUtils::compareAndSwap((void**)&validatorMutex, tmpMutex, 0)
returns 0. If it is deleted by XMLPlatformUtils, I don't see it. Please
help.
Siehnai Williamson
DocuCorp International, Inc.
Tel: (214) 891-6401
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
RE: Memory leak
Posted by Erik Rydgren <er...@mandarinen.se>.
Hi!
My memory checking tool also reported this but it is actually correct.
The compareAndSwap just does an atomic assignment to a pointer.
So if validatorMutex is 0 it will get the value of tmpMutex and the fuction
returns true.
Or if validatorMutex already was set the function leaves it and returns
false.
Although the validatorMutex is never deleted, however my application doesn't
have any problems with that so I didn't dig any deaper. Xerces leaks ONE
instance of XMLMutex in total. It will not leak one for each Parse.
Regards
Erik Rydgren
Mandarinen systems AB
Seden
-----Original Message-----
From: Williamson, Siehnai [mailto:swilliamson@docucorp.com]
Sent: den 17 oktober 2001 23:38
To: 'xerces-c-dev@xml.apache.org'
Subject: Memory leak
Hi Everyone,
There appears to be a memory leak in the SAX parser during validation. It
occurs at the line XMLMutex* tmpMutex = new XMLMutex in the
gVAlidatorMutex() method of the XMLValidator class (see below):
*****
static XMLMutex& gValidatorMutex()
{
static XMLMutex* validatorMutex = 0;
if (!validatorMutex)
{
XMLMutex* tmpMutex = new XMLMutex;
if (XMLPlatformUtils::compareAndSwap((void**)&validatorMutex,
tmpMutex, 0))
{
// Someone beat us to it, so let's clean up ours
delete tmpMutex;
}
}
return *validatorMutex;
}
*****
tmpMutex appears to never have been deleted if
XMLPlatformUtils::compareAndSwap((void**)&validatorMutex, tmpMutex, 0)
returns 0. If it is deleted by XMLPlatformUtils, I don't see it. Please
help.
Siehnai Williamson
DocuCorp International, Inc.
Tel: (214) 891-6401
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org