I see some people asked about GC.Collect(), for example:
I see that in general, people say: CG is smart enough to collect garbage on it own, premature optimization is bad.
But according to the document:
Use this method to try to reclaim all memory that is inaccessible. It performs a blocking garbage collection of all generations.
All objects, regardless of how long they have been in memory, are considered for collection; however, objects that are referenced in managed code are not collected. Use this method to force the system to try to reclaim the maximum amount of available memory.
So I see that this GC.Collect()
command only delete the data that is no longer used, I can't think of any risk that it may cause, so what is the risk of calling GC.Collect()? Is it bad for the PC's hardware?