Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
This console application never stop. always in running mode. Why automatic garbage collection not happening?

Please help me.
Thanks.
Posted
Updated 6-Apr-14 17:39pm
v4
Comments
ZurdoDev 26-Mar-14 7:18am    
Maybe it is happening. Perhaps you have an infinite loop that is eating up the memory.
[no name] 26-Mar-14 7:27am    
Hi, in c# automatic garbage collection predefined right. no need to write any coding.
Kornfeld Eliyahu Peter 26-Mar-14 7:33am    
But you have to release your object, before GC can collect them!
ZurdoDev 26-Mar-14 7:40am    
Correct. All you need to do is make sure you are disposing of your objects properly. That may mean that they go out of scope, or it may mean that you have them in a using statement, etc.
Kornfeld Eliyahu Peter 26-Mar-14 7:22am    
Do you have the code? We may figure out some answers from there...

1 solution

The garbage collector is probably still running and working, but you are not releasing any of the memory that you are using. This program reads what is presumable a rather large file into memory to process, so if this file is larger then the amount of memory available then you will need to look into another method of accessing this file.

Two debugging techniques that can help work out why this application never finishes are:

1) Put lots of System.Diagnostics.Debug.WriteLine("Specific line identifier"); messages in the code and look at the output window to see what lines are being executed when it gets stuck. Look at why the loop never terminates. Tip: in a for (;;) loop include the index as part of the debug message.

2) Comment out huge swathes of code until the application successfully runs through. When it does re-introduce the commented code until it does not finish and you have found your problem code.
 
Share this answer
 
Comments
Dave Kreskowiak 1-Apr-14 9:48am    
Unfortunately, for this guy, the solution is not going to be "comment out chunks of code".

This is code is written so badly that it's unsupportable. He REALLY needs to scrap all of this and rewrite it, from scratch, in a modular form. By doing do, he could also inadvertantly solve the OutOfMemory problem at the same time without even trying.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900