java - Sandbox for memory -
java supposed not have memory leaks it's still possible. when program has memory leak can fix (i hope). when third party packages have can do? practically nothing except don't using package.
is there solution? idea of sandbox. allowed whatever want within area , "physical" don't have ability bother other outside of box. there way create such sandbox memory usage in java? imagine = create sandbox memory usage, allow package whatever does, take results , delete sandbox whatever garbage left here! no complications gc, no cleaning or disposition of memory. delete , forget it.
is there way so?
the best way launch jvm, communicate with socket(for example), , kill jvm after it's done.
it'll interesting discuss whether can sandbox within same jvm.
after done using 3rd party library, , no longer referencing objects library, garbage that's still lingering?
their classes - though not referening of them, if loaded same classloader code, these classes persist. , static fields reference more lingering data, , forth
threadlocal - have set thread local variables, , not cleaned them up
thread - have spawned threads persist
in global place - e.g. system.setproperty() - it'll stay there.
so in general, it's difficult.
however, can use separate classloader , separate thread execute 3rd party library, , strategy can unload garbages created 3rd party, in cases.
are there existing tools doing that? i'm not knowledgeable that. have experience implementing hot reloadable server, , have utility classes can used purpose. example
// wrap 3rd party code, expose java.*.* interface public class mywrapper implements callable<string> { @override public string call() { return thirdparty.query(..); } } hotreloader hot = new hotreloader(); callable<string> func = (callable<string>)hot.getappinstance("pkg.mywrapper"); string result = func.call(); // dereference `hot` , `func`
see hotreloader
Comments
Post a Comment