ghci should have stricter use of memory with module reloading
After loading modules, ghci tends to retain memory allocated for the loaded modules after reloading. In my work project, when I change a module which is at the top of the dependency and therefore forces recompilation of all the previously modules when realoding, the live data and the heap space allocated are almost doubled. The next reloading does not cause the tripled live data, so it seems like a one-time redundancy issue in ghci module loading/unloading. If I unload all the module and load again, it does not show the retaining behavior (I also checked the unloading is done completely with -fghci-leak-check), so it is more related to reloading process.
I attached the comparison of the heap profile. The first one is the data from running ghci with loading modules and reloading, and the second one is from running ghci with loading modules and unloading (:l) and loading the modules again. This is on GHC 9.4.2.