How to reclaim the memory manually
-
Hi, I know GC does memory management manually. If i want to manually reclaim the memory of an object, how can I do it. Thanks Devin
Of a single object, you cannot. In general, you can call
GC.GarbageCollect()
to force a garbage collection, however this is not recommended as the system is tuned to perform this at optimal times.
My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
-
Of a single object, you cannot. In general, you can call
GC.GarbageCollect()
to force a garbage collection, however this is not recommended as the system is tuned to perform this at optimal times.
My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
-
Sorry, I was going from memory. I meant
GC.Collect()
From MSDN: GC.Collect()[^]: Forces garbage collection for all generations.
My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
-
Sorry, I was going from memory. I meant
GC.Collect()
From MSDN: GC.Collect()[^]: Forces garbage collection for all generations.
My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
-
I think using GC.Collect we achieve finalization not memory reclaimation. Is I am right. Explain.
It will reclaim the memory. If an object requires it then the finaliser will be called first. The finalisation process is inefficient and objects that have finalisers will also have a
Dispose()
method. So, you should callDispose()
on an oject if it has that method. TheDispose()
method will generally suppress the finalisation on that object making garbage collection more efficient.
My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
-
It will reclaim the memory. If an object requires it then the finaliser will be called first. The finalisation process is inefficient and objects that have finalisers will also have a
Dispose()
method. So, you should callDispose()
on an oject if it has that method. TheDispose()
method will generally suppress the finalisation on that object making garbage collection more efficient.
My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More