📜  c# 计算一个对象占用多少内存

📅  最后修改于: 2022-03-11 14:49:05.484000             🧑  作者: Mango

代码示例1
long size = 0;
object o = new object();
using (Stream s = new MemoryStream()) {
    BinaryFormatter formatter = new BinaryFormatter();
    formatter.Serialize(s, o);
    size = s.Length;
}