Closed
Bug 36191
Opened 26 years ago
Closed 24 years ago
Too many array classes, and a couple of them leak
Categories
(Core :: XPCOM, defect, P3)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
People
(Reporter: briansmith, Assigned: scc)
References
()
Details
(Keywords: memory-leak)
Attachments
(1 file)
There are two memory leaks in ns[C]StringArray:
http://lxr.mozilla.org/seamonkey/source/xpcom/ds/nsVoidArray.cpp#307
http://lxr.mozilla.org/seamonkey/source/xpcom/ds/nsVoidArray.cpp#496
These delete the array of pointers without deleting the objects the pointers
point to. The quick fix is to change |delete mArray;| to |Clear()|. I will
submit a patch for this later in the day (when I get off work). My suggestion
for a better fix for this bug is:
1. Move nsObjectArray and nsObject to XPCOM from i18n to XPCOM
(http://lxr.mozilla.org/seamonkey/ident?i=nsObjectArray)
(http://lxr.mozilla.org/seamonkey/ident?i=nsObject). This will provide a
general solution for this type of problem, and I'm sure that many places
besides XPCOM.
2. Have nsString and nsCString inherit from nsObject so that they that
nsStringArray and nsCStringArray can be implemented using nsObjectArray
3. Reimplement nsCStringArray and nsStringArray using nsObjectArray. This will
cut down on some code duplication in these classes.
4. Reimplement nsObjectArray on top of nsVoidArray, further reducing code
duplication.
There a bug on nsVoidArray (#29873) that I could fix in the process. Also,
there is an item in the XPCOM TODO about removing the single dependency on
nsVector (http://lxr.mozilla.org/seamonkey/ident?i=nsVector) so that nsVector
and PLVector can be removed. I could take submit patches for this. The second
bug on nsVoidArray (#26030) may require an interface change to that class and
I'd like feedback before I try to tackle that one.
Please let me know if you want me to go ahead with the changes I listed above.
Perhaps the best part is that they have nothing to do with UTF-8!
- Brian
| Reporter | ||
Comment 1•26 years ago
|
||
Sorry, I cut the end of #1 off: "I'm sure that many places besides XPCOM and
i18n would benefit from nsObjectArray".
| Reporter | ||
Comment 3•26 years ago
|
||
| Reporter | ||
Comment 4•26 years ago
|
||
I submitted a context-diff patch implementing the "quick fix" mentioned above.
The patch compiled and Mozilla runs with no noticable difference on my machine.
I tried to do before-and-after leak reports but Mozilla would always hang when
loading xpinstal.dll with logging enabled.
The array classes can be made much simpler and smaller than they are now--
nsStringArray and nsCStringArray can be turned into wrapper classes and be
inlined away to nothing. I will work on points (1)-(4) and bug #29873 above if
scc approves.
Updated•26 years ago
|
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Target Milestone: --- → M18
Comment 5•26 years ago
|
||
mass re-assigning to my new bugzilla account
Assignee: scc → scc
Status: ASSIGNED → NEW
| Assignee | ||
Updated•26 years ago
|
Status: NEW → ASSIGNED
Keywords: mlk
Updated•25 years ago
|
QA Contact: leger → kandrot
| Assignee | ||
Updated•25 years ago
|
OS: other → All
Hardware: PC → All
Target Milestone: M18 → ---
Comment 6•24 years ago
|
||
I verified that both the mentioned leaks do not exist in the current code.
Array of pointers is being deleted only after deleting the objects the pointers
point to.
I'm not sure about the other suggestions as in that case inheritance will
surely cause some overhead.
| Assignee | ||
Comment 7•24 years ago
|
||
the leaks are fixed according to the last comment, and as to major re-design of
collection classes... well.. someday but leaving _this_ bug open won't make it
happen any sooner.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•