1. When creating an object, finalize takes more time because the object needs to be put in the finalization list.
2. Finalize will make your applicationProgramIt is slower to run because additional checks are required for each object during GC.
3. Finalize will put more pressure on the memory (heap memory allocation problems)
4. the execution time of finalize is uncertain. If you want to use exclusive resources such as file, the person who wants to use the file cannot determine when to use the file, in this case, it is better to use dispose or close to release resources as soon as possible,
This also means that you cannot manually control the execution of finalize and its execution sequence.
PS: When to execute finalize?
1. When the 0-generation object in the managed heap is full, GC is started.
2.CodeExplicitly execute the GC. Collect Method
3. The system memory is too low.
4. Uninstall an application domain (appdomain)
5. CLR disabled
PS: Finalize execution timeout
The finalize execution timeout time of a single method is 2 seconds.
The total finalize time of all objects cannot exceed 40 seconds.