My (C# .NET 4.0) application runs over a period of days, updating a simulated account according to changes in prices acquired from a SQLite database.
All I need on any particular date is the account in its current state and the latest prices. I'd expect that the Garbage Collector would keep memory usage on a fairly even keel: what I'm seeing is a steady increase in Working Set and Private Memory (as reported by System.Diagnostics.GetCurrentProcess()
) and also in GC.GetTotalMemory(true)
: about 300K per day in this case. Inevitably, the whole thing crashes after about 12 simulated years, at which point the memory use has increased by about 1GB.
Memory usage increases more-or-less linearly, (very much more smoothly if I force a GC.Collect()
at the end of each day).
I'm inferring that some objects are somehow not garbage-collectible, even when I think there's no further need for them and had expected that they would be cleaned up in the normal ebb and flow of execution.
What might I try to identify where I've inadvertently managed to create such a situation?
I've downloaded and run CLRProfiler - it's going to take the best part of the weekend to digest the documentation, though, and there's no guarantee that it'll be able to help.
I'm working through the references in this question. In general, I know what kind of situation can be causing the problem, I'm more interested to see if there are faster ways to identify the specifics without spending precious days working through my code ticking off references...
NOTE: The problem doesn't appear to be event-related and there's no graphic component involved.