有一些關於 How to get object size in memory ? 的文章,但它們沒有解釋如何獲取內存中對象的大小。在內存中獲取DataTable或ArrayList的大小
當我使用:
System.Runtime.InteropServices.Marshal.SizeOf(arrayListObject)
我得到錯誤:
Type 'System.Collections.ArrayList' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed.
我也無法得到可用的存儲量,becouse我想執行上與Web應用程序這個計算很多線程,所以需要知道具體對象需要多少內存。
除非你仍然停留在.NET 1.1,否則不應該使用'ArrayList'。如果您需要包含任何對象的列表,請使用'列表
問題不是關於使用對象的方式,現在我正在使用DataTable – 2010-03-09 05:19:39