The ClearGlobalEnvironment is doing the following:
this.Evaluate("rm(list=ls())");
This doesn't remove hidden objects.
It should instead do:
this.Evaluate("rm(list=ls(all=TRUE))");
In addition, it might be useful to add the detach() command (to unload all packages), but this should be optional (by an argument to the function) as sometimes, between requests, it is good to leave loaded packages.
And one last thing, it might be recommended to perform the CLR garbage collection twice:
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
This is because the finalizers execute after the first collection and you want to collect whatever they left behind.
Comments: Improvements with commit: Revision: 276 Changeset: e3d77416d5e04bef0ad9389bcb8faf06ca56bbc2 [e3d77416d5e0] Parents: 275 Branch: jperraud
this.Evaluate("rm(list=ls())");
This doesn't remove hidden objects.
It should instead do:
this.Evaluate("rm(list=ls(all=TRUE))");
In addition, it might be useful to add the detach() command (to unload all packages), but this should be optional (by an argument to the function) as sometimes, between requests, it is good to leave loaded packages.
And one last thing, it might be recommended to perform the CLR garbage collection twice:
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
This is because the finalizers execute after the first collection and you want to collect whatever they left behind.
Comments: Improvements with commit: Revision: 276 Changeset: e3d77416d5e04bef0ad9389bcb8faf06ca56bbc2 [e3d77416d5e0] Parents: 275 Branch: jperraud