From b40fe867e021bc365df1a904c2b1ed2068208f13 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Mon, 23 Feb 2015 02:54:41 +0100 Subject: implemented to undo stack memory limiting * acts as a safe-guard against uninterrupted infinite loops or other operations that are costly to undo in interactive mode. If we're out of memory, it is usually too late to react properly. This implementation tries to avoid OOMs due to SciTECO behaviour. We cannot fully exclude the chance of an OOM error. * The undo stack size is only approximated using the UndoToken::get_size() method. Other ways to measure the exact amount of allocated heap (including size fields in every heap object or using sbrk(0) and similar) are either costly in terms of memory or platform-specific. This implementation does not need any additional memory per heap object or undo token but exploits the fact that undo tokens are virtual already. The size of an undo token is determined at compile time. * Default memory limit of 500mb should be OK for most people. * The current limit can be queried with "2EJ" and set with ,2EJ. This also works interactively (a bit tricky!) * Limiting can be disabled. In this case, undo token processing is a bit faster. * closes #3 --- src/interface.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/interface.h') diff --git a/src/interface.h b/src/interface.h index cf9aef6..8f37668 100644 --- a/src/interface.h +++ b/src/interface.h @@ -64,7 +64,7 @@ class View { return *(ViewImpl *)this; } - class UndoTokenMessage : public UndoToken { + class UndoTokenMessage : public UndoTokenWithSize { ViewImpl &view; unsigned int iMessage; @@ -74,8 +74,7 @@ class View { public: UndoTokenMessage(ViewImpl &_view, unsigned int _iMessage, uptr_t _wParam = 0, sptr_t _lParam = 0) - : UndoToken(), view(_view), - iMessage(_iMessage), + : view(_view), iMessage(_iMessage), wParam(_wParam), lParam(_lParam) {} void @@ -85,7 +84,8 @@ class View { } }; - class UndoTokenSetRepresentations : public UndoToken { + class UndoTokenSetRepresentations : public + UndoTokenWithSize { ViewImpl &view; public: @@ -158,7 +158,7 @@ class Interface { return *(InterfaceImpl *)this; } - class UndoTokenShowView : public UndoToken { + class UndoTokenShowView : public UndoTokenWithSize { ViewImpl *view; public: @@ -169,7 +169,7 @@ class Interface { }; template - class UndoTokenInfoUpdate : public UndoToken { + class UndoTokenInfoUpdate : public UndoTokenWithSize< UndoTokenInfoUpdate > { Type *obj; public: -- cgit v1.2.3