Closed
Bug 25190
Opened 25 years ago
Closed 25 years ago
ns*String::ToNew* must be matched with Recyle, not delete
Categories
(Core :: CSS Parsing and Computation, defect, P3)
Core
CSS Parsing and Computation
Tracking
()
VERIFIED
INVALID
People
(Reporter: hjtoi-bugzilla, Assigned: pierre)
Details
(Keywords: memory-leak)
Attachments
(1 file)
(deleted),
patch
|
Details | Diff | Splinter Review |
In layout/html/style/src we have, in nsCSSValue and nsHTMLValue, a member
variable that we set with nsString::ToNewValue and then try to release with
simple delete. This is twice wrong. First, it is a an array we are trying to
release (and hence we should use delete []) but even this is not correct.
nsString comments say that the call ToNew* must be matched with a call to
Recycle (the memory is not allocated with new). I noticed this with Purify.
Attaching patch next.
Reporter | ||
Comment 1•25 years ago
|
||
Changing component to Style System and reassigning
Assignee: troy → pierre
Component: Layout → Style System
QA Contact: petersen → chrisd
Reporter | ||
Comment 3•25 years ago
|
||
Damn, I messed up my patch. I wasn't using the latest source etc. Recycle only
works for char* and PRUnichar*. nsString::Recycle takes nsString*, but does
nothing.
My guess (I am recompiling everything, latest source, to make sure) is to
replace the Recycle calls in the patch with calls to nsAllocator::Free.
I'll try to run Purify again to see how much memory this saves with
launch/shutdown and attach the Purify log. Maybe I'll spot some other places
where this occurs as well.
Reporter | ||
Comment 4•25 years ago
|
||
Bad day. I was seeing ghosts. ToNewString allocates the new string with new and
thus freeing it with delete is the right way. I was seeing memory leak because
of some old code where the parent object was not released and I thought this was
the reason. Also confused this a bit with the other ToNew* methods. Sorry.
Marking invalid.
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•