Il 29/09/2011 00:30, Jean-Marc Lasgouttes ha scritto:
Le 29/09/2011 00:05, Tommaso Cucinotta a écrit :
Also, I noticed a monotonic memory usage increase while editing the
document and especially creating math insets and deleting them later. I
guess this is due to the Undo feature, that keeps storing (a copy of)
all the insets even though you delete them from the document, until you
close the document (or probably save).
We actually limit the number of undo steps (to 100?)
Yes, I found it (UndoElementStack::limit_).
Though, I have some doubts about how UndoElement instances are handled.
a) they're pushed into the stack *by value*
std::deque<UndoElement> c_;
so, more instances of UndoElement are created and copied wastefully:
void push(UndoElement const & v) {
c_.push_front(v);
furthermore, if the internal representation of dequeue<> uses an
array, then
we waste more memory for the unused entries than we would, if it were
a dequeue<UndoElement*>.
b) the UndoElement class contains pointers to MathData and ParagraphList
which are created by new
if (cell.inMathed()) {
[...]
undo.array = new MathData(ar.buffer(), ar.begin(), ar.end());
} else {
[...]
undo.pars = new ParagraphList(first, last);
}
stack.push(undo);
but apparently never deleted:
~UndoElement()
{
if (isFullBuffer)
delete bparams;
}
Am I missing something here ?
Thanks,
T.