Adding, removing MenuItem, does not release memory?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Well, after developing a plugin based architecture, with lots of menuitems, i
found that after adding a menuitem, and later removing, results in increased
memory.
I know all that thing with Dispose, finalizers, garbage collector, and so
on, they do not help.

'try this, to see a how fast memory grows.

dim i as int32
Dim m As New MenuItem("ok")
for i = 1 to 10000
Me.Menu.MenuItems.Add(m)
Windows.Forms.Application.DoEvents()
Me.Menu.MenuItems.Remove(m)
Me.Text = GC.GetTotalMemory(True).ToString
next

'however other controls does not leave their stuff
Dim m As New Label
dim i as int32
for i = 1 to 10000
Me.Controls.Add(l)
Windows.Forms.Application.DoEvents()
Me.Controls.Remove(l)
Me.Text = GC.GetTotalMemory(True).ToString
next
 
Back
Top