개체가 메모리에서 차지하는 크기

1691 단어 메모리
this may not be accurate but its close enough for me
long size =0;object o =newobject(); using (Stream s =newMemoryStream()){BinaryFormatter formatter =newBinaryFormatter(); formatter.Serialize(s, o); size = s.Length;}

private long ObjectSize(object o)
        {
            long size = 0;
            //object o = new object();
            using (Stream s = new MemoryStream())
            {
                BinaryFormatter formatter = new BinaryFormatter();
                formatter.Serialize(s, o);
                size = s.Length;
            }
            return size;
        }

좋은 웹페이지 즐겨찾기