I have a Visual Studio addin for Visual Studio 2010 which evaluates a number of expressions (including variables in the current stack frame). It is making repeated calls to:
foreach (EnvDTE.Expression expression in dte.Debugger.CurrentStackFrame.Locals)
and
dte.Debugger.GetExpression("CanSerializeToString(" + expression + ")", false);
and
dte.Debugger.GetExpression("SerializeToString(" + expression + ")", false);
where "SerializeToString" methods are defined in the client application being debugged.
I've noticed that the more expressions it evaluates, the slower it gets. When I expanded the contents of an array, I can sit and watch as it takes over a second to evaluate each array element expression, and each one takes longer than the previous.
Is there some kind of cleanup I need to do after evaluating an expression so it doesn't get slower and slower and slower?