Question:
In .NET Compact Framework, can I free memory explicitly without waiting for garbage collector to free the memory?
Answer:
ya you can clear the memory using gc.collect method but it is recommanded that u should not call this coz we dont know the exact time when the gc will be called automaticle. Source: CoolInterview.com
No it not possible Source: CoolInterview.com
Answered by: Bimal Chandra Patel | Date: 12/28/2007
| Contact Bimal Chandra Patel
System.GC.Collect() forces garbage collector to run. though it is not recommended to use as it may hamper the performance of your application. You can use Dispose() method alternatively Source: CoolInterview.com
Answered by: Karunish | Date: 6/8/2009
| Contact Karunish
gc.Collect is only request to garbge collector for freeing the memory ocupied by an object.There is no guaranteed way to clear the memory occupied by a managed object. Source: CoolInterview.com
Answered by: Mahesh | Date: 6/22/2009
| Contact Mahesh
Actually the answer is no, as the GC decides on its own when to perform or not, even if you call .Collect() . Collect doesn't force any collection, it just indicates a signal and since GC is a deamon thread,and its priority is very low, it is likely that no collection will happen instantly.
The same goes for .Dispose for unmanaged resources, you mark the object and you never know the exact time that memory got freed. Source: CoolInterview.com
Answered by: Sidar Ok | Date: 7/7/2009
| Contact Sidar Ok
Yes, it is possible We can call GC.Collect method to clear out memory explicitly. Source: CoolInterview.com
Answered by: Pradeep Soni | Date: 9/15/2009
| Contact Pradeep Soni
GC is not an application level process. It is controlled by dotnet frame work. No other application can force or control GC. Application can mark the object is obselate and it is not required further more. GC works in a periodic time interval. It frees the memmories when it run Source: CoolInterview.com
Answered by: san | Date: 2/11/2010
| Contact san
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|