Closed LeftofZen closed 3 months ago
I have also found that recreating the index simply increases memory usage, meaning the previous index is being leaked. Time to rewrite how it works since I just ported it from the winforms version without thinking about mvvm
For those interested, the main cause here was that I was using a static dictionary to store objects, and this dictionary was never cleared, ever. This is why recreating indexes always consumed more memory - it would just get added to without removing anything. The original reason for this dictionary was that vehicles needed to look up cargo types to load correctly, so you needed to load cargo types first and have a reference to them globally (or otherwise pass to the vehicles), and this is how I did it. However the vehicle loading code has gone through multiple iterations and at some stage I implemented a better solution, meaning the static global dictionary was no longer necessary, but I forgot to delete it's usage. Removing all of that has removed the main memory issue as far as I can tell.
Users are reporting huge (27gb!) memory usage when loading folders and viewing them. This is insane, and whilst I don't get the same issue on my pc (only 700mb usage) I believe the AvaloniaUI TreeView is the issue as it doesn't virtualise the list items. This is confirmed in the memory profiler as all the newly-allocate ram is from Avalonia. This performance page indicates switching to TreeDataGrid may help as it virtualises items.