473,395 Members | 1,656 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Adding, removing MenuItem, does not release memory?

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
Jul 21 '05 #1
1 1367
Giedrius,

Removing memory has to do with the time it is done and the references that
are set. Therefore you can mostly not force it how hard you try, it is
managed by the framework, and two captains on a ship gives never a good
result.

Insert by instance the row I inserted in your code bellow and see the
difference. (now the label is never showed)

A link about this all is this.

http://msdn.microsoft.com/architectu...l/scalenet.asp

I hope this helps a little bit?

Cor

"Giedrius" <Gi******@discussions.microsoft.com>
Dim m As New Label
dim i as int32 m.visable = false for i = 1 to 10000
Me.Controls.Add(l)
Windows.Forms.Application.DoEvents()
Me.Controls.Remove(l)
Me.Text = GC.GetTotalMemory(True).ToString
next

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: alan | last post by:
Hi all, I have a problem on release memory. If I delcare the following pointer to pointer char, how can I free the allocated memory ? let say "myVar = 20" <---actually it is not a constant,...
4
by: Eric Sabine | last post by:
I've simplified the code to the following. I'm just overlooking something very simple I'm sure. Dim mic() As MenuItem mic = New MenuItem(3) {} mic(0) = New MenuItem("a") mic(0).Index = 1 ...
1
by: Giedrius | last post by:
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...
1
by: prashant_sharma | last post by:
Hi, Following code is creating assertion Please help me to release memory occupied by Char array.. char *nm = new char; strcpy(nm,"Prashant"); delete nm; Thanks in Advance
6
by: laikon | last post by:
Hi, everyone, below is my program to test static pointer data member; class A { private: static A* p; protected: A() {} public: static A* init()
16
by: eflatunn | last post by:
Hi all, my problem is that the application doesn't terminate when I close the form using the close box on the caption bar. Actually it seems as if the program is closed but task manager's process...
2
by: mina | last post by:
hi i am using vb.net 2005 to my desktop application. my problem is like this when i am running my project it occupies 100% cpu at 1st form load. then again it release memory upto 95%. when i am...
2
by: Hugh Oxford | last post by:
I have a site that uses Yahoo maps. I place markers on the maps - the images for the markers reside on my webserver. The site also uses polylines. I find that when I add a batch of markers,...
36
by: mynews | last post by:
I use free() function to release memory, But the memory usage is still increasing. cygwin #include <stdio.h> #include <stdlib.h> #include <string.h> struct queue{
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.