473,597 Members | 2,459 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Garbage Collector / ContextMenu / Dispose / General dotnet bug/issues?

I've got a form with a usercontrol and a contextmenu for it. I put
everything together in the VS form designer. the codesnipped below is
from that dialog.

The problem: Before i added the cmObjektTree.Di spose() call in the
forms' dispose function, the garbage collector didn't collect my form
and everything on / related to it if i opened the contextmenu (and in
popup is no code that does anything else than setting the
visible/disabled states of menuitems). if i don't open it everything
is collected perfectly. i think it has something to do with the events
of the menuitems in the contextmenu. Seems that ContainerContro l calls
dispose on all the controls on it but it and its base classes don't
care about disposing the contextmenu?

In this special case i can solve the problem by calling the dispose
function of contextmens manually wherever i use one or create own base
classes derived by form and usercontrol that *do* care about disposing
the contextmenu but i'm not sure if there are more such problems and
there has to be a proper way to do things without wasting the
memory.... or not?
ps: i'd like to see the form classes' code to see what microsoft
exactly does e.g. in the dispose function of containercontro l and what
not.

-Codesnippet--------------------------------------------------------------------------
private void cmObjektTree_Po pup(object sender, System.EventArg s e)
{
cmiExpandCollap se.Text = objektTree.Acti veNodeExpanded ?
"&Reduziere n" : "E&rweitern ";
cmiExpandCollap se.Enabled = cmiExpandAll.En abled =
objektTree.Acti veNodeExpandabl e;
updateMenuState s();
}

protected override void Dispose( bool disposing )
{
cmObjektTree.Di spose(); // <== ********* I added this ***********

if(disposing && components != null)
components.Disp ose();
base.Dispose(di sposing);
}
Nov 16 '05 #1
0 1212

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

Similar topics

6
810
by: Ganesh | last post by:
Is there a utility by microsoft (or anyone) to force garbage collection in a process without have access to the process code. regards Ganesh
28
3335
by: joe | last post by:
I have a simple .NET application with two or three listViews which are filled with icons and when the user click on the proper item, they display the related images. I use "image = null ; " for all images that have been used and are going to be closed. This is how ever no way to reduce the memory consumption. I have noticed , using the task manager, that garbage collector doesn't actually do any collections unless the computer becomes low...
18
3062
by: Rein Petersen | last post by:
Is there any way to adjust thread priority for the garbage collector? Would be nice if I could tune the thread priority rules for the garbage collector too... From my readings of the process, when memory becomes limited, the garbage collector is moved up in priority. I believe they must be overly simplified explanations because I would tend to guess that Microsoft would have allowed for more pre-emptive reclaiming of memory to best...
10
2293
by: Ray5531 | last post by:
Is there a way in C# to stop garbage collector from killing our object automatically.I'd like to kill it myself?? Is there away to to do so? Thanks
36
1900
by: André | last post by:
Hello, I have a c# application that creates a timer to fire every minute using multithreading. On every minute it calls a Ping class that I made using sockets. It creates a new ping class then sets it to null when it’s done. I noticed every time this class gets created I see the memory keeps getting larger. I think I should add Idisposable to my ping class and dispose of the memory
5
5486
by: Ben | last post by:
Could someone please verify if what I am doing as follow is corrected: 1. when dealing with custom class objects: ..... public myObject as myClass myObject as New myClass .......here I am going to fill up myObject with info....tons of them myObject = nothing System.GC.Collect()
14
2914
by: Christian Kaiser | last post by:
We have a component that has no window. Well, no window in managed code - it uses a DLL which itself uses a window, and this is our problem! When the garbage collector runs and removes our component (created dynamically by, say, a button click, and then not referenced any more), the GC runs in a different thread, which prohibits the DLL to destroy its window, resulting in a GPF when the WndProc of that window is called - the code is gone...
4
2351
by: PromisedOyster | last post by:
There are various contradictory newsgroup postings on this issue, but I would really like a definitive answer from the .NET gurus out there? We have various WinForms that contain multiple Icons and Bitmaps that are loaded onto the form dynamically, eg control.Icon = ;. Should we explicitly Dispose of these unmanaged resources when the form closes OR should we leave it up to the garbage collector to remove these (and will it definitively...
8
1781
by: Paul.Lee.1971 | last post by:
Hi everyone, A program that I'm helping to code seems to slow down drastically during initialisation, and looking at the profiling graph, it seems to be the garbage collector thats slowing things down. I must point out that a heck of a lot of data are being read in and manipulated, and I was wondering if there were any metrics to show much of a performance hit is occurring during the initialisation? If it turns out that the GC is having a...
0
7893
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8276
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8381
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8040
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8259
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5847
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3932
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2408
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1495
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.