I'm building an app to display the historical log of changes from a source control repository. The app is implemented in .NET 4 WPF and Entity Framework Code First.
One of the problems I'm getting is that over time, as more log entries are added to the log, the application uses more and more memory and doesn't release references to the log entries. Each log entry holds a list of "changed files" and for each changed file, the before and after version of the file.
The UI displays a list of log entries and the diff between the old and new version of the currently selected LogEntry
and ChangedFile
. The data model is roughly as follows:
public class LogSubscription
{
public List<LogEntry> Log { get; set; }
}
public class LogEntry
{
public List<ChangedFile> ChangedFiles { get; set; }
}
public class ChangedFile
{
public string OldVersion { get; set; }
public string NewVersion { get; set; }
}
As I'm using EF Code First, the database is queried and the object model is built automatically by simply accessing the List properties. What I'd like to do is somehow de-reference the ChangedFiles
list after a certain time and have the database re-queried and the object model rebuilt as necessary (i.e. the user has clicked back onto the log entry).
Is there any way to do this with EF Code First? Or should I be taking a different approach to control the memory used?
The app and full source code is hosted on GitHub here: https://github.com/tomhunter-gh/SourceLog