Details
Description
In Shared mode deployment, peer-class-loading behavior causes the server to run out of memory(metaspace) if the client starts ,sends compute task, , and often stops. I dump the JVM heap and found GridDeploymentClassLoader class without unloading.I then debugged it locally and found the following code in the GridResourceProcessor class, which passed a null value into the ioc.descriptor method, causing the GridResourceIoc's taskMap property not to store the corresponding information, which in turn caused the GridResourceIoc's onUndeploy method not to unload the clsDescs corresponding class information (and possibly other references), which caused OOM.
//ignite 2.8.0 GridResourceProcessor class 261-267 line private void inject(Object obj, GridResourceIoc.AnnotationSet annSet, @Nullable GridDeployment dep, @Nullable Class<?> depCls, Object... params) throws IgniteCheckedException { GridResourceIoc.ClassDescriptor clsDesc = ioc.descriptor(null, obj.getClass()); …… }
Test code:
//client code public class Task implements IgniteRunnable { private int num; public Task(int j) { this.num = j; } @Override public void run() { System.out.println(num); } }
//client start code final IgniteConfiguration configuration = new IgniteConfiguration(); configuration.setPeerClassLoadingEnabled(true); configuration.setClientMode(true); for (int i = 0; i < 10000; i++) { final Ignite start = Ignition.start(configuration); start.compute().run(new Task(i)); start.close(); }
// server -XX:MaxMetaspaceSize=100m final IgniteConfiguration igniteConfiguration = new IgniteConfiguration(); igniteConfiguration.setPeerClassLoadingEnabled(true); final Ignite ignite = Ignition.start(igniteConfiguration);