From 304bc9702c9c18f4db5d4ac88864988b4b3f0bbe Mon Sep 17 00:00:00 2001
From: Rainer Kartmann <rainer.kartmann@kit.edu>
Date: Wed, 26 May 2021 17:48:36 +0200
Subject: [PATCH] Limit history size of object instance segment by default

---
 .../ArMemObjectMemory/config/ObjectMemory.cfg | 20 +++++++++++++++++--
 .../armem_objects/server/instance/Segment.h   |  3 ++-
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/scenarios/ArMemObjectMemory/config/ObjectMemory.cfg b/scenarios/ArMemObjectMemory/config/ObjectMemory.cfg
index 77b3f690f..df483eb31 100644
--- a/scenarios/ArMemObjectMemory/config/ObjectMemory.cfg
+++ b/scenarios/ArMemObjectMemory/config/ObjectMemory.cfg
@@ -215,6 +215,22 @@ ArmarX.AdditionalPackages = ArmarXObjects
 # ArmarX.ObjectMemory.mem.articulated.inst.MaxHistorySize = -1
 
 
+# ArmarX.ObjectMemory.mem.attachments.CoreSegmentName:  Name of the object instance core segment.
+#  Attributes:
+#  - Default:            Attachments
+#  - Case sensitivity:   yes
+#  - Required:           no
+# ArmarX.ObjectMemory.mem.attachments.CoreSegmentName = Attachments
+
+
+# ArmarX.ObjectMemory.mem.attachments.MaxHistorySize:  Maximal size of object poses history (-1 for infinite).
+#  Attributes:
+#  - Default:            -1
+#  - Case sensitivity:   yes
+#  - Required:           no
+# ArmarX.ObjectMemory.mem.attachments.MaxHistorySize = -1
+
+
 # ArmarX.ObjectMemory.mem.cls.CoreSegmentName:  Name of the object clazz core segment.
 #  Attributes:
 #  - Default:            Class
@@ -303,10 +319,10 @@ ArmarX.AdditionalPackages = ArmarXObjects
 
 # ArmarX.ObjectMemory.mem.inst.MaxHistorySize:  Maximal size of object poses history (-1 for infinite).
 #  Attributes:
-#  - Default:            -1
+#  - Default:            25
 #  - Case sensitivity:   yes
 #  - Required:           no
-# ArmarX.ObjectMemory.mem.inst.MaxHistorySize = -1
+# ArmarX.ObjectMemory.mem.inst.MaxHistorySize = 25
 
 
 # ArmarX.ObjectMemory.mem.inst.calibration.offset:  Offset for the node to be calibrated.
diff --git a/source/RobotAPI/libraries/armem_objects/server/instance/Segment.h b/source/RobotAPI/libraries/armem_objects/server/instance/Segment.h
index 54314054a..5b7c268bb 100644
--- a/source/RobotAPI/libraries/armem_objects/server/instance/Segment.h
+++ b/source/RobotAPI/libraries/armem_objects/server/instance/Segment.h
@@ -159,7 +159,8 @@ namespace armarx::armem::server::obj::instance
         struct Properties
         {
             std::string coreSegmentName = "Instance";
-            long maxHistorySize = -1;
+            // -1 would be infinite, but this can let the RAM grow quickly.
+            long maxHistorySize = 25;
             bool discardSnapshotsWhileAttached = true;
         };
         Properties p;
-- 
GitLab