Question

I'm working on a WebFlow application that runs off of a single 'master' flow. This flow stores a large number of objects on the flow scope for communication between subflows. For some of these objects, I can verify that they are no longer needed and I'd like to manually free them for garbage collection rather than wait for the user to log out.

Is there a clean way to do this, or is it a bad idea?

Was it helpful?

Solution

The closest thing you can do is to remove all strong references to the objects which are not longer needed. You should be doing this as good practice any way. e.g. clearing collections of objects you don't need any more and close()ing resources as soon as they are not needed (even though the GC will probably do this for you)

This will maximise the number objects the GC can collect at any point in the program.

In turn the GC reduces total pause time and maximises efficiency by only running when it needs to. Running it more often than needed usually reduces the throughput the program, unless you have a very simple workflow and a very clear point where most (say 80+%) of the memory can be cleaned up.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top