473,474 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

memory never been collected

I am developing C# application that every 10 seconds refreshes TreeView
control. I am using 3 custom classes for renewing the TreeView control.

And It seems that I do not free some resources, so every 10 seconds the
memory used by my application is increasing ( I was monitoring that
from task manager ) I know that because of the way Garbage Collector
works, it is not recommended to trust the task manager so I downloaded
AQtime ( http://www.automatedqa.com/ ) and monitoring my application
with this software it turned out that every 10 seconds a new instance
of my custom classes are created, and they are not released. I've
tested the application for 5 minutes and I had 30 instances, and the
used memory was still growing up. This software have a function to
force the garbage collection, and I have tried it - the count dropped
to 7. I've forced the garbage collector again - the count was 1.
As far as I am informed how the GC is working isn't it supposed to
start every time it need new memory?
Actually I find this very strange. Can someone help?
Somewhere in Internet I read that it is not recommended to call the
Garbage Collector ( GC.Clollect() ). Can you tell me whether this is
true and if yes why.

Thanks.

Nov 17 '05 #1
3 1118
As far as I am informed how the GC is working isn't it supposed to
start every time it need new memory?
Right. Unless those 30 instances take up significant amounts of memory
I wouldn't worry.

Somewhere in Internet I read that it is not recommended to call the
Garbage Collector ( GC.Clollect() ). Can you tell me whether this is
true and if yes why.


Because then you're trying to outsmart the garbage collector. It's
almost always best to just let it do what it does best and not
interfere.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 17 '05 #2
Hi ,

That's true , GC definitely comes into the picture but our dude has a
"undeterministic" tag associated with it so , it doesn't bother itself
till there's a real shortage of memory and compaction is required for
new allocations - in simple words , however i am dead sure things are
much more complex than this .

Also , it's been suggested not to GC.collect explicitly until and unless
really required since , this will add to object retention ,as it places
your object in finalization queue , in first GC run , that means ready
for collection next time , so , even when it will ensure definite
garbage collection , it will happen in 2 cycles instead of normal one ,
where there was a chance to miss it if it had some references or was
reachable .

Mrinal

Mattias Sjögren wrote:
As far as I am informed how the GC is working isn't it supposed to
start every time it need new memory?

Right. Unless those 30 instances take up significant amounts of memory
I wouldn't worry.
Somewhere in Internet I read that it is not recommended to call the
Garbage Collector ( GC.Clollect() ). Can you tell me whether this is
true and if yes why.

Because then you're trying to outsmart the garbage collector. It's
almost always best to just let it do what it does best and not
interfere.

Mattias

Nov 17 '05 #3

"Mrinal Kamboj" <mr***********@oracle.com> wrote in message
news:pU**************@news.oracle.com...
Hi ,

Also , it's been suggested not to GC.collect explicitly until and unless
really required since , this will add to object retention ,as it places
your object in finalization queue , in first GC run , that means ready for
collection next time , so , even when it will ensure definite garbage
collection , it will happen in 2 cycles instead of normal one , where
there was a chance to miss it if it had some references or was reachable .

Note that this is only true for objects that have destructors, object that
don't have destructors never end on the finalization queue. The same is true
for objects implementing the Dispose pattern, provided Dispose() was called
before object "destruction".

Willy.
Nov 17 '05 #4

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

Similar topics

9
by: Chris S. | last post by:
Is it possible to determine how much memory is allocated by an arbitrary Python object? There doesn't seem to be anything in the docs about this, but considering that Python manages memory...
3
by: Ian Taite | last post by:
Hello, I'm exploring why one of my C# .NET apps has "high" memory usage, and whether I can reduce the memory usage. I have an app that wakes up and processes text files into a database...
7
by: Matthias Kwiedor | last post by:
Hi@all! I have a app (c#) where i load up a external dll (managed code from c#) with a small arraylist and hashtable in two routines (about 40000 objects in each arraylist and hashtable). If...
25
by: Zeng | last post by:
I finally narrowed down my code to this situation, quite a few (not all) of my CMyClass objects got hold up after each run of this function via the simple webpage that shows NumberEd editbox. My...
3
by: anonymous | last post by:
I believe I ran into an interesting way to create memory leaks in C# 2.0 using anymous delegates. Here is a sample of the code in question. private void Handle_Event(object sender, EventArgs e)...
8
by: Adrian | last post by:
Hi I have a JS program that runs localy (under IE6 only) on a PC but it has a memory leak (probably the known MS one!) What applications are there that I could use to look at the memory usage of...
47
by: docschnipp | last post by:
Does such a function result in a memory leak because of not explicitely setting result = null? ------------------ public override string GetValueAsString() { StringBuilder result = new...
22
by: Frank Rizzo | last post by:
I have an object tree that is pretty gigantic and it holds about 100mb of data. When I set the top object to null, I expect that the .NET framework will clean up the memory at some point. ...
1
by: Frank Rizzo | last post by:
I have an application (windows service) that in the beginning reads data rapidly into a collection of large object trees. Each object tree in the collection is about 100mb and typically there are...
2
by: Jack Jackson | last post by:
On Wed, 11 Jun 2008 07:32:30 +0200, "Fred" <foleide@free.fr.invalid> wrote: If the control will soon be eligible for garbage collection, then no. If the control won't be eligible for garbage...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.