摘要:
使用WeakReference 来释放那些长时间在内存中无用的大对象测试代码:View Code using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Text;using System.Runtime.Serialization.Formatters.Binary;namespace WeakReferenceTestSample{ public class SomeBigClass : List<string> { public So... 阅读全文
摘要:
this may not be accurate but its close enough for melong 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(); ... 阅读全文