得到的名单,其中字节数; T> [英] Get byte size of List<T>

查看:128
本文介绍了得到的名单,其中字节数; T>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

愚蠢的问题,但在WinForms应用程序即时通讯目前正在研究,我想获得分配的字节/使用量的名单,LT; SomeObject]> 保存在内存中(用于统计目的)。这可能吗?我已搜查直通可能的选项,但显然没有 myList.GetTotalBytes()方法。

Silly question, but in a winforms app Im currently working on, I would like to get the amount of bytes allocated/used by a List<[SomeObject]> held in memory (for statistical purposes). Is this possible? I have searched thru the possible options, but there is obviously no myList.GetTotalBytes() method.

推荐答案

我不知道在运行时提供获取对象的大小的可靠的编程方法,但也有一些选项开放给你:

I'm not sure the runtime provides a reliable programmatic method of getting an object's size, however there are some options open to you:

  • 使用像CLR分析器
  • 系统工具
  • 使用<一个href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.sizeof.aspx">Marshal.SizeOf() (返回对象的非托管大小)
  • 在一个近似序列化对象的二进制
  • use a tool like CLR Profiler
  • use Marshal.SizeOf() (returns the unmanaged size of the object)
  • serialize your object to binary for an approximation

这篇关于得到的名单,其中字节数; T&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆