Hi Jason,
Yes you are removing the shapes correctly. If the shapes are however connected you may consider the NBatchDelete to perform the removal. For an example see the following topic:
Diagram for .NET > User's Guide > Document Object Model > Batches
The memory leak may occur if you locally subscribe for events of the shapes for example like that:
shape.BoundsChanged += somedelegate;
Because we wanted to optimize the memory footprint and performance of shapes, the shapes do not have local events declared on them, but rather use the EventSinkService to record "per node" events. This helps us for example temporary "block" all events when performance is required - for example during BeginUpdate()/EndUpdate() of the drawing.
You are right however that this can generate a memory leak. To detach a shape from all events for which you have locally subscribed you can use the following code:
drawingdocument.EventSinkService.RemoveAllNodeEventListeners(shape);
Best Regards,
Nevron Support Team