473,382 Members | 1,420 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,382 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 1366
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{
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.