I have a standard CRUD application that works with a fairly large amount of data. Different windows access different tables using Linq-To-SQL, and each window essentially has a grid with cells bound to the objects I'm displaying.
Here's a pretty standard use case of what's happening:
- Open Window A
- Close Window A - Window A is now still in memory but no longer visible.
- Open Window B
- Close Window B - Windows A and B are now both in memory and neither are visible.
- Open Window C
- As data is retrieved for Window C, resources for Window A are released.
So at any given time I have 2-3 windows held in memory, when all I should really have is one. I have even added disposal code to the closing event for these windows which sets all of the references I can think of to null.
I tried using the ANTS memory profiler, and I'm noticing that each window is set as a GC root. Is there a way to disable this behavior or somehow force the GC to collect from these windows?
Thanks!
PS: I have checked this link and it didn't resolve the issue.
EDIT: The problem is that the users are getting System.OutOfMemoryExceptions.