DataTable 内存大小的内存分析

Memory Profiling on DataTable memory size

我在这里对我的应用程序进行了内存分析,试图找出数据表在我的应用程序上消耗了多少内存。

但是,有人可以告诉我如何找出数据表的大小吗?

我只是从 DataTable 类型实例中读取吗?或者我应该将所有内容的大小相加(例如:DataRowCollection、DataColumnCollection、DataTable 等)?

谢谢。

在 VS 的诊断工具视图中,为您的应用程序拍摄快照:

然后,单击对象 diff link:,

在快照选项卡中,有一个过滤器输入,您可以按类型名称过滤,输入"DataTable",然后单击"view instances of datatable"按钮:

在下一个屏幕中,您将查看数据表实例的一个或多个实例。 Inclusive Size 为您提供对象的完整尺寸:

根据 Microsoft documentation

Inclusive Size (Bytes): The size of the instances of the type, or the size of a single instance, including the size of contained objects.