I can't free proc memory used by my EF DbContext. In spite of dispose and GC.Collect, my application don't free memory.
I created a little program :
static void Main(string[] args) { var test = new TestDb(); System.Threading.Thread.Sleep(1000); // Here proc memory = 7 Mo test.Fill(); System.Threading.Thread.Sleep(1000); // Here proc memory = 58 Mo test.Dispose(); System.Threading.Thread.Sleep(1000); // Here proc memory = 37.8 Mo test = null; GC.Collect(); // Here proc memory = 37.8 Mo // Why is not 0 here ??? System.Threading.Thread.Sleep(1000); } You can show memory usage with my comments.
TestDb Class :
public class TestDb : IDisposable { private List<TaskAction> _actions; public void Fill() { using (var entities = new myEntities()) { entities.Configuration.LazyLoadingEnabled = false; _actions = entities.TaskActions.ToList(); } } public void Dispose() { _actions = null; GC.Collect(); } } How can I free all used memory ??
Thanks,
Charly