Closed Bug 25765 Opened 26 years ago Closed 26 years ago

Leaking DeleteRangeTxn objects

Categories

(Core :: DOM: Editor, defect, P3)

defect

Tracking

()

VERIFIED FIXED

People

(Reporter: beard, Assigned: mozeditor)

References

()

Details

(Keywords: memory-leak)

The URL above hilites the creation of a DeleteRangeTxn object, and then that it is appended to a EditAggregateTxn. The problem is, when the object is created via TransactionFactory::GetNewTransaction(), it has a refCount of 1, and EditAggregateTxn::AppendChild() adds another. Thus, when the EditAggregateTxn releases the DeleteRangeTxn, it still has a refCount of 1, so it leaks. Here's a patch that fixes it for me: Index: mozilla/editor/base/nsEditor.cpp =================================================================== RCS file: /cvsroot/mozilla/editor/base/nsEditor.cpp,v retrieving revision 1.239 diff -c -2 -r1.239 nsEditor.cpp *** nsEditor.cpp 2000/01/18 23:52:23 1.239 --- nsEditor.cpp 2000/01/30 18:19:47 *************** *** 4561,4564 **** --- 4561,4565 ---- else result = NS_ERROR_OUT_OF_MEMORY; + NS_IF_RELEASE(txn); } else
Sounds like a joe thang.
Assignee: sfraser → jfrancis
accepting / m15
Status: NEW → ASSIGNED
Target Milestone: M15
Blocks: 26388
Keywords: mlk
Summary: [MLK] Leaking DeleteRangeTxn objects → Leaking DeleteRangeTxn objects
everywhere we use "aTxn->AppendChild(txn)" we need to release txn. This is actually in a few places. Alternatively I could just rewrite those places to not explicitly use the aggregate txn stuff, which is pretty manual, and instead use the placeholder batching. All of the CreateTxnForDeleteElemetn(), CreateTxnForDeleteText(), etc calls could just be replaced with DoDeleteElement(), DoDeleteText(), etc, which directly executed the txn. Placeholder batching would automagically handle wrapping up the txns into a single undoable operation, and also correctly manage the addreffing of the subtransactions.
fixed
Status: ASSIGNED → RESOLVED
Closed: 26 years ago
Resolution: --- → FIXED
verified
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.