RobotStudio event

RS SDK - Memory Leakage via CommandBarPopup



Hi there,
 
I just thought I'd pass on an observation that I've made about a possible memory leakage associated with a CommandBarButtonGroup event handler.
 
I have found that after synchronising a group of paths to the VC using...
 
result = task.SyncPathProcedure(path.ModuleName + "/" + path.Name, SyncDirection.ToController, messages);
... I then find that the memory usage for RobotStudio.exe started running away, increasing until it tops out at over 2GB.
 
After trying to locate the cause of this leak, I eventually tracked it down to the DisplayCommandGroupEventHandlers that I am using for showing a dynamically updated CommandBarButtonGroup underneath a series of CommandBarPopup menus.  In the DisplayCommandGroupEventHandler, if I call... 
 
e.AddItem(string caption, object tag, Image image, bool isChecked, bool isEnabled);
 
...to update the items that should appear in the button group, then this memory leakage problem occurs, although only after using the SyncPathProcedure() call.  As far as I can tell there is no link between the parameters I am passing to e.AddItem() and the synchronisation procedure.
 
To solve this leakage problem, I have had to set the CommandBarPopup "Enabled" state to...
 
popup.Enabled = CommandBarPopupEnableMode.Enabled;
 
... which only updates the state of the popup when the button is pressed, rather than the default enabled state of "CommandBarPopupEnableMode.Dynamic", which appears to update the CommandBarButtonGroup whenever it can.  However, it's interesting that this memory leakage only appears to happen after I synchronise paths, so if someone could explain why this is the case I would be very interested.  Smile