473,320 Members | 2,029 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,320 software developers and data experts.

should I help Garbage Collector?

Hi,
[Windows Forms]
I have a panel in which I create lots of controls (a few hundreds,
this.panel1.Controls.Add(...) ) , but they are there only for a short
while - when user pushes button I call clear panel, and populate it with
another (brand new) set of controls.
Currently, I leave the cleaning job to GC, and just don't care, but
perhaps I could help him somehow?

Piotrek
Nov 16 '05 #1
3 924
On 09 Jul 2004 11:38, "Piotrek Stachowicz" wrote:
Hi,
[Windows Forms]
I have a panel in which I create lots of controls (a few hundreds,
this.panel1.Controls.Add(...) ) , but they are there only for a short
while - when user pushes button I call clear panel, and populate it with
another (brand new) set of controls.
Currently, I leave the cleaning job to GC, and just don't care, but
perhaps I could help him somehow?

Piotrek

You're much better off leaving it that way, probably. Make sure that you
unsubscribe from any events on the control's you're getting rid of, though.
--
Simon Smith
simon dot s at ghytred dot com
www.ghytred.com/NewsLook - NNTP Client for Outlook
Nov 16 '05 #2
No, sod it. The GC will love you - it will have a chance to execute its rarely-used-but-essential algorithms.
NEVER try to help the GC - it does a very complex job in a very elegant way - it is very sophisticated in its ways of not actually releasing memory if it's only going to be using it again in a short while, saving on a lot of processor time and memory allocation resources, giving it a 'managed memory pool', hence the term, managed. It is this sophisticated 'managed pooling' that gives .NET programs an advantage over raw C++ programs.

"Piotrek Stachowicz" wrote:
Hi,
[Windows Forms]
I have a panel in which I create lots of controls (a few hundreds,
this.panel1.Controls.Add(...) ) , but they are there only for a short
while - when user pushes button I call clear panel, and populate it with
another (brand new) set of controls.
Currently, I leave the cleaning job to GC, and just don't care, but
perhaps I could help him somehow?

Piotrek

Nov 16 '05 #3
Piotrek,

Profile your application with CLR Profiler or any other working for you and
see if there is need to help GC. Check relocated objects and time line. If
users are doing heavy input through this panel you might need to do certain
actions. But before doing anything check also recommendations in
http://msdn.microsoft.com/architectu...l/scalenet.asp

HTH
Alex

"Piotrek Stachowicz" <dy******@poczta.onet.pl> wrote in message
news:cc**********@news.onet.pl...
Hi,
[Windows Forms]
I have a panel in which I create lots of controls (a few hundreds,
this.panel1.Controls.Add(...) ) , but they are there only for a short
while - when user pushes button I call clear panel, and populate it with
another (brand new) set of controls.
Currently, I leave the cleaning job to GC, and just don't care, but
perhaps I could help him somehow?

Piotrek

Nov 16 '05 #4

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

Similar topics

1
by: Bob | last post by:
Are there any known applications out there used to test the performance of the .NET garbage collector over a long period of time? Basically I need an application that creates objects, uses them, and...
0
by: Andrew | last post by:
When will .NET have a low-pause-time garbage collector A low-pause-time garbage collector would greatly improve .NET's ability to serve as a platform for soft real-time systems. It doesn't have...
4
by: Pedro Miguel Carvalho | last post by:
Greetings. I'm creating a project that as a intricate relation between object kind of like a set where each object in the set can be connect to a subset of object of the set and objects not in...
10
by: pachanga | last post by:
The Hans-Boehm garbage collector can be successfully used with C and C++, but not yet a standard for C++.. Is there talks about Garbage Collector to become in the C++ standard?
18
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,...
13
by: Mingnan G. | last post by:
Hello everyone. I have written a garbage collector for standard C++ application. It has following main features. 1) Deterministic Finalization Providing deterministic finalization, the system...
28
by: Goalie_Ca | last post by:
I have been reading (or at least googling) about the potential addition of optional garbage collection to C++0x. There are numerous myths and whatnot with very little detailed information. Will...
83
by: deppy_3 | last post by:
Hi.I am started learning Programm language C before some time.I am trying to make a programm about a very simple "sell shop".This programm hasn't got any compile problem but when i run it i face...
3
by: a.mustaq | last post by:
Hi All, When an object is not is used for a long time, it will be removed by Garbage Collector. How can we avoid the Garbage Collector not to remove the object though it has not been used for a...
13
by: Ramon F Herrera | last post by:
I am writing a program that generates source code. See a snippet below. My question is about the use of that growing 'code' variable. Is it efficient? Is is recommended for this case? The code...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...

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.