On 21/09/2015 16:08, Phil Clayton wrote:
What I am actually observing is that finalizers are not run on exit for finalizable values that are in scope in the top-level environment. On exit, the REPL has finished, so shouldn't such values be garbage collected and therefore finalized?
I noticed that but it's very difficult to fix. The problem is that the top level environment is an array contained in the executable. It is treated as "initialised data" by the linker and loader. The garbage collector treats mutable data in the executable as roots for garbage collection which means it never has to look at the immutable data in the executable. The only way I can see of fixing the problem is to copy all the data, both mutable and immutable, from the executable into the heap.
As I wrote that it occurred to me that there might be some way of processing the current finaliser list during the shut-down process so that only weak refs that were referenced by other finalisers were preserved. This would allow the detection of dependencies, which is what is really needed at that point. This would be much cheaper and could be done instead of the current call to PolyML.fullGC.
I've merged the current Finalizer branch into master on github. David _______________________________________________ polyml mailing list polyml@inf.ed.ac.uk http://lists.inf.ed.ac.uk/mailman/listinfo/polyml