# Segment Editor undo queue length

**URL:** <https://discourse.slicer.org/t/segment-editor-undo-queue-length/14766>\
**Category:** Development\
**Created:** [November 25, 2020, 12:51pm UTC](https://discourse.slicer.org/t/segment-editor-undo-queue-length/14766 "2020-11-25T12:51:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hherhold](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hherhold/32/12199_2.png) [@hherhold](https://discourse.slicer.org/u/hherhold)\
**Post date:** [November 25, 2020, 12:51pm UTC](https://discourse.slicer.org/t/segment-editor-undo-queue-length/14766/1 "2020-11-25T12:51:12Z")

</div>

How much memory is used up when the state is saved for Undo in Segment Editor? Sometimes when working with really large datasets (\>10GB) in Segment Editor I will tweak `SegmentEditorWidget.setup()` to set `self.editor.setMaximumNumberOfUndoStates(10)` to something like 1 or even zero.

This _seems_ to help but I have not done any quantitative comparisons. If it actually _does_ use less memory, would it be useful to have a configurable “Number of undo steps” setting in Segment Editor?

(I’m happy to look into doing this if it would be useful.)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 25, 2020, 5:57pm UTC](https://discourse.slicer.org/t/segment-editor-undo-queue-length/14766/2 "2020-11-25T17:57:14Z")

</div>

A copy of each modified segmentation layer (3D volume containing non-overlapping segments) is stored in each undo state. You can check the process memory usage to see if it makes a significant difference for you.

Number of undo states could be exposed somewhere on the GUI (maybe in application settings / segmentations), but this adds a little bit of complication and room for user error (user changing this setting to 0 at some point for testing something and then forget about it and not understanding why undo does not work). So, I would only add this if there is a strong, confirmed need for it.

---

<div class="post-metadata">

**Author:** ![hherhold](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hherhold/32/12199_2.png) [@hherhold](https://discourse.slicer.org/u/hherhold)\
**Post date:** [November 25, 2020, 5:59pm UTC](https://discourse.slicer.org/t/segment-editor-undo-queue-length/14766/3 "2020-11-25T17:59:55Z")

</div>

Yeah, I only do it for big datasets with complicated segmentations. I think I’ll just continue with tweaking the source when necessary. I can definitely see where someone might change this in a configuration and forget about it, or inherit a config file and get confused.

Thanks!

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 25, 2020, 6:02pm UTC](https://discourse.slicer.org/t/segment-editor-undo-queue-length/14766/4 "2020-11-25T18:02:14Z")

</div>

> [@hherhold](#):
>
> I think I’ll just continue with tweaking the source when necessary

You don’t need to tweak the source - you can change the number of undo states by a one-line command.

---

<div class="post-metadata">

**Author:** ![hherhold](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hherhold/32/12199_2.png) [@hherhold](https://discourse.slicer.org/u/hherhold)\
**Post date:** [November 25, 2020, 6:06pm UTC](https://discourse.slicer.org/t/segment-editor-undo-queue-length/14766/5 "2020-11-25T18:06:07Z")

</div>

DOH! Yes, this is now painfully obvious. (Insert embarrassed emoji here.)

Thanks!!!
