You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by th...@ascentialsoftware.com on 2002/11/26 20:57:25 UTC
Memory leaks in STD library
We are slowly replacing every usage of istrstream, ostrstream in our code by
our own classes as it seems, at least on windows 2000 using VC++ 6.0, that
there are very big memory leaks in those classes.
Is it something that anyone else experienced as well or is something
surprising and we are may be doing something wrong somewhere?
The memory leaks we are experiencing are big enough to make our application
crash after processing 20000 XML documents (~10 to 40 Kb per document) on a
P4 machine with 512 Meg of memory.
Tomas
Re: Memory leaks in STD library
Posted by David N Bertoni/Cambridge/IBM <da...@us.ibm.com>.
Hi Thomas,
I suspect it's misuse on your part. Remember, with istrstream and
ostrstream, after you call str(), you must either delete the pointer you
get back, or call freeze(false) to tell the stream to unfreeze the memory:
ostrstream msg;
msg << "foo" << '\0';
cout << msg.str();
msg.freeze(false);
or
ostrstream msg;
msg << "foo" << '\0';
const char* const data = msg.str();
cout << data;
delete [] data;
Dave
thomas.cherel@ascentials
oftware.com To: xalan-c-users@xml.apache.org
cc: (bcc: David N Bertoni/Cambridge/IBM)
11/26/2002 11:57 AM Subject: Memory leaks in STD library
We are slowly replacing every usage of istrstream, ostrstream in our code
by our own classes as it seems, at least on windows 2000 using VC++ 6.0,
that there are very big memory leaks in those classes.
Is it something that anyone else experienced as well or is something
surprising and we are may be doing something wrong somewhere?
The memory leaks we are experiencing are big enough to make our application
crash after processing 20000 XML documents (~10 to 40 Kb per document) on a
P4 machine with 512 Meg of memory.
Tomas