C# Programming - Constructors - Discussion

Discussion Forum : Constructors - General Questions (Q.No. 11)
11.
Is it possible to invoke Garbage Collector explicitly?
Yes
No
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
9 comments Page 1 of 1.

John said:   1 decade ago
// Put some objects in memory.
MyGCCollectClass.MakeSomeGarbage();
Console.WriteLine("Memory used before collection: {0:N0}",
GC.GetTotalMemory(false));

// Collect all generations of memory.
GC.Collect();
Console.WriteLine("Memory used after full collection: {0:N0}",
GC.GetTotalMemory(true));

Sam said:   9 years ago
Yes, we can do it either by "using " statement or inheriting ID is possible interface.

Somnath said:   1 decade ago
@Usha is right Dispose method is used to explicitly call GC.

Swami said:   1 decade ago
How it is possible, I don't understand could you explain. ?

Usha said:   1 decade ago
Dispose method is used to explicitly invoke a destructor.

Karishma sahu said:   1 decade ago
True, we can call GC using System.GC.Collect() method.
(1)

Anusha said:   1 decade ago
By using GC.Collect() method.

Sujeettiwari said:   1 decade ago
@Ausha you are correct.

Irfan said:   1 decade ago
By using destructor.

Post your comments here:

Your comments will be displayed after verification.