DanielKote / Foreman2

Visual planning tool for Factorio
Other
162 stars 16 forks source link

Old DataCache object is not destroyed when reloading settings #31

Closed arik123 closed 1 year ago

arik123 commented 2 years ago

Steps to reproduce:

  1. Start foreman
  2. Open settings
  3. Go to Graph Options
  4. Toggle Load barelling crafting recipes
  5. Confirm
  6. Observe memory usage

Possible cause

There is most likely some reference to the old DataCache left even after it is replaced with the new one, so the GC keeps it alive.

gillett-hernandez commented 1 year ago

i confirmed the cause by running a memory snapshot before and after and comparing reference counts. upon loading a new preset there's two unique DataCaches in memory. this might take a bit to fix since afaik you'd have to go through all references to DataCaches and maybe put breakpoints or otherwise investigate which references don't get reassigned to the newly constructed DataCache.

mrozpara commented 1 year ago

IMHO: DataCache should be moved from ProductionGraphView to mainForm - that will allow to have multiple files (tabs) opened (first step to have it), and in meantime all references/assignment will have to be reviewed...