CustomObject Memory Undo Stack [C#]

Hi all,

Using Rhinocommon I’m having memory problems with the undo stack using custom objects. When adding a CustomMeshObject to the Document with some other class instances inside (meshes, parameters, whatever you need inside the custom object) the ram usage is being affected but it doesn’t affect to the limit for the undo stack. I mean, the undo stack is not doing the purge when the memory usage is higher than the limit.

To test this I created a CustomMeshObject with a mesh Sphere(Size = 10x10) that has inside
another sphere mesh (Size = 1000x1000) that uses a lot of memory. If you drag the object about 10 times, the document purge event is not being called despite the memory usage goes above 1000MB(according to windows) and 1200MB(according to Rhino). My memory limit at options is 256MB. Seems that Rhino does not take into consideration to the undo stack this elements inside the custom objects. I tried to use the UserData and UserDictionary inside the Geometry of the custom objects but the result is almost the same.

Do you know a workaround for this? I attach the test project with a command “UndoPurgeDataCommand” which adds a sphere and you can check the memory usage dragging it (how it is being increased) and the purge for the undo stack is not being called. Also you have an UserData class in case you want to test with it too.

It’s happening under Rhino 5 and the Rhino WIP latest version. (54.4 KB)


I remember asking this question a while ago. The solution at the time was to use C++ and derive from ON_UserData.

Thanks for your answer @menno, this could be a workaround for that. I also tried writting a new MemoryEstimate() method of the CustomObjects but seems Rhino is not using it for the stack (also this method is not virtual in the base object so it couldn’t be overridden)


I don’t have a resolution that I can suggest for this, at this time. But I’ve make a YouTrack item so we can address this going forward.

– Dale