清除数据表的好处

伊万

我想知道完成后清除数据的数据表是否有好处,如果我不清理表,是否有明显的问题。我知道清除表的过程只有一行,但是我想知道它提供的好处,并且在退出应用程序运行时是否将自动清除表,还是保留这些表直到重启计算机?

例子:

Me.dtSet.Tables("ExampleTable").Clear()
马克C.

请看这个主题

它从本质上说,处置DataSet / DataTable没有任何好处。

还:

DataSet and DataTable don't actually have any unmanaged resources, so Dispose() doesn't actually do much. The Dispose() methods in DataSet and DataTable exists ONLY because of side effect of inheritance - in other words, it doesn't actually do anything useful in the finalization.

It turns out that DataSets, DataViews, DataTables suppress finalization in their constructorsc this is why calling Dispose() on them explicitly does nothing.

Presumably, this happens because, as mentioned above, they don’t have unmanaged resources; so despite the fact that MarshalByValueComponent makes allowances for unmanaged resources, these particular implementations don’t have the need and can therefore forgo finalization.

Overview of this Immense Answer:

Without a doubt, Dispose should be called on any Finalizable objects.

DataTables are Finalizable.

Calling Dispose significantly speeds up the reclaiming of memory.

MarshalByValueComponent calls GC.SuppressFinalize(this) in its Dispose() - skipping this means having to wait for dozens if not hundreds of Gen0 collections before memory is reclaimed.

这里开始,作者:Killercam

如果那些没有完全回答您的问题,请阅读此答案

您的问题的重要要点->

Does Dispose() method does not free up the memory & make object as null ??

处置,处置模式不是用于回收托管内存或“删除”托管对象(您不能做的事情以及垃圾收集器的用途),而是用于处置/释放非托管资源或其他具有资源的托管资源可释放项,例如SqlConnection。它当然不会使引用无效,但可能会使它自废弃之日起就无法使用。”

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章