2
想知道是否有人试图确定内存中System.Collections.Generic.List的实际大小?System.Collections.Generic.List <T>内存大小
我目前正在缓存一个这样的对象使用System.HttpRuntime.Cache这似乎工作正常,但我希望能够确定对我的服务器的实际影响。
using (System.IO.MemoryStream stream = new System.IO.MemoryStream(capacity))
{
new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter().Serialize(stream, obj);
thisSerialized = stream.ToArray();
return thisSerialized.Length;
}
这适用于其他人,但不适合我需要的东西。
我从来没有尝试过使用IntPtr获得大小,如果你碰巧有一个代码段,我会喜欢它。 – hal9000 2011-02-24 20:23:54
@Hal:你不能。 IntPtr.Size表示32/64位;它是单个参考的大小。 – SLaks 2011-02-24 21:08:52