DomainContext 在创建实例时会消耗大量内存。如果实例是局部变量,看起来内存没有自动释放,代码如下:
MyDomainContext ctx = new MyDomainContext();
....
ctx=null;
如何为 DomainContext 的实例释放内存?
DomainContext 在创建实例时会消耗大量内存。如果实例是局部变量,看起来内存没有自动释放,代码如下:
MyDomainContext ctx = new MyDomainContext();
....
ctx=null;
如何为 DomainContext 的实例释放内存?
DomainContext doesn't implements IDisposable so you must rely on GarbageCollector to free up your memory. Be sure to remove any reference to the DomainContext instance than call System.GC.Collect()
You shouldn't bother about the entities loaded by the domaincontext and still referenced somewhere in the code, as long as I know WCF Ria services keep only a WeakReference to them