VSTO 4.0 Excel 2007 Add-in causing Memory leaks on Windows 7
We have a VSTO 4.0 Add-in for Excel 2007 that seems to have issues with Memory leaks, but only certain documents and only on Windows 7. The behavior is similar to the 开发者_如何学运维LCID proxy issue that was supposedly remedied in VSTO 4. The memory spikes at about 1.2 to 1.5 GB then throws an OutOfMemory Exception. This only seems to happen when I try to open certain documents when runing on Windows 7. If I open the same documents in XP, the memory certain goes high but I do not get an exception. Basically, I get various exceptions and never in the same place twice:
----- Source: System.Windows.Forms -----
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.Windows.Forms.Screen.FromRectangle(Rectangle rect)
at System.Windows.Forms.Screen.GetWorkingArea(Rectangle rect)
at System.Windows.Forms.WindowsFormsUtils.ConstrainToScreenWorkingAreaBounds(Rectangle bounds)
at System.Windows.Forms.ToolStripDropDown.GetDropDownBounds(Rectangle suggestedBounds)
at System.Windows.Forms.ToolStripDropDown.SetBoundsCore(Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified)
at System.Windows.Forms.Control.SetBounds(Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified)
at System.Windows.Forms.Control.set_Size(Size value)
at System.Windows.Forms.ToolStripDropDown.AdjustSize()
at System.Windows.Forms.ToolStripDropDown.OnLayout(LayoutEventArgs e)
at System.Windows.Forms.ToolStripDropDownMenu.OnLayout(LayoutEventArgs e)
at System.Windows.Forms.Control.PerformLayout(LayoutEventArgs args)
at System.Windows.Forms.Control.System.Windows.Forms.Layout.IArrangedElement.PerformLayout(IArrangedElement affectedElement, String affectedProperty)
at System.Windows.Forms.Layout.LayoutTransaction.DoLayout(IArrangedElement elementToLayout, IArrangedElement elementCausingLayout, String property)
at System.Windows.Forms.ToolStripItem.InvalidateItemLayout(String affectedProperty, Boolean invalidatePainting)
at System.Windows.Forms.ToolStripItem.InvalidateItemLayout(String affectedProperty)
at System.Windows.Forms.ToolStripItem.OnRightToLeftChanged(EventArgs e)
at System.Windows.Forms.ToolStripDropDownItem.OnRightToLeftChanged(EventArgs e)
at System.Windows.Forms.ToolStripItem.OnOwnerChanged(EventArgs e)
at System.Windows.Forms.ToolStripMenuItem.OnOwnerChanged(EventArgs e)
at System.Windows.Forms.ToolStripItem.SetOwner(ToolStrip newOwner)
at System.Windows.Forms.ToolStripItemCollection.SetOwner(ToolStripItem item)
at System.Windows.Forms.ToolStripItemCollection.Add(ToolStripItem value)
at Hcg.Stinger.Report.ShadowRangeTree.ShadowRangeNodeEventBehavior.AddDynamicLabelMenu() in C:\Serenity6.x\Source\Hcg\Stinger\Report\ShadowRangeTree\ShadowRangeNodeEventBehavior.cs:line 135
Here's another one:
----- Source: System.Windows.Forms -----
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.Windows.Forms.ToolStripManager.ProcessShortcut(Message& m, Keys shortcut)
at System.Windows.Forms.ToolStripManager.ProcessCmdKey(Message& m, Keys keyData)
at System.Windows.Forms.ContainerControl.ProcessCmdKey(Message& msg, Keys keyData)
at System.Windows.Forms.Form.ProcessCmdKey(Message& msg, Keys keyData)
at System.Windows.Forms.Control.ProcessCmdKey(Message& msg, Keys keyData)
at System.Windows.Forms.Control.ProcessCmdKey(Message& msg, Keys keyData)
at System.Windows.Forms.TextBoxBase.ProcessCmdKey(Message& msg, Keys keyData)
at System.Windows.Forms.Control.PreProcessMessage(Message& msg)
at System.Windows.Forms.Control.PreProcessControlMessageInternal(Control target, Message& msg)
at System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg)
When I save the documents as stand alone docs and do not open them using the VSTO Add-in, it is able to open them with minimal memory. When I use the add in to open them, that's when things spin up and crash.
Any help or pointers as to why Windows 7 has these issues would be much appreciated.
Thanks,
Erick
Actually, I figured out the the application was creating thousands of ToolStripMenuItems for context menus on TreeNodes. Once I made those shared, it took care of the memory issue.
精彩评论