Problems about Dispose ()

xiaoxiao2021-03-06  99

When I read the DotNet document with a beautiful mood, Dispose entered my sight.

First of all, I realize what I said in the document, some objects must be manually called, not a joke. This requirement mentioned in the document is serious. For example, SqlConnection, although you don't manually call Dispose or Close can be used in some cases, because the system will automatically call those in some cases; however, in additional cases, non-calling Dispose or Close will cause the connection pool to be quickly Consume clean.

Second, Dispose makes me feel very frustrating, which is not more easily controlled than C wonderful HEAP memory pointers. Just now we have determined that Dispose (or similar alternative) is necessary to manually call for some objects, otherwise it will be prone to problems. OK, let me find it, if we have forgotten in some place, we can hardly confirm which damn place forgot to release; and the forgotten place, it may precisely lead to resources to exhaust; and until resources consumption Before you do it, you almost impossible to discover this problem; and when the resources are exhausted, you have no way to detect when you are exhausted. If you find such a problem in a large project module, there will be someone to go crazy; so some people say that DOTNET is not suitable for the big project, how much is a bit reasonable. In contrast, the C HEAP memory pointer is also needed, but we can at least easily detect memory leaks.

转载请注明原文地址:https://www.9cbs.com/read-97034.html

New Post(0)