Troubleshooting JVM Memory Growth Issues
Check for a continuous increase in the memory footprint of the JVM, record it, warning.
Operations Discovery Application JVM memory consumption after release, and then continue to increase, after the dump analysis:
Most of the memory is the bean with similar names, where does it produce so many similar beans?
The app uses the dynamic language groovy, which dynamically gets the script execution when the logic is requested.
The core code is that the groovy script is turned into a spring IOC-managed bean and needs to be injected with other beans:
Public<T> T getscriptedobject (String scriptname, String scriptsource, class<t>CLS) { if(Stringutils.isempty (scriptsource))Throw NewRuntimeException ("service script" + scriptname + "Empty"); Groovyobject Goo=NULL; Class CLZ=NULL; Try{CLZ=Groovyclassloader.parseclass (Scriptsource); Goo=(Groovyobject) clz.newinstance (); if(NULL!=beanfactory) {beanfactory.autowirebeanproperties (Goo,1,true); } } Catch(Unsatisfieddependencyexception ex) {//ex.printstacktrace ();}Catch(Exception ex) {Logger.error ("Script {} exception: {}", ScriptName, ex); Throw NewRuntimeException (ex); } if(Cls.isassignablefrom (Goo.getclass ())) {return(T) goo; } Else { Throw NewRuntimeException ("script" + scriptname + "error"); }}
The code that produces the bean must be a number of examples:
beanfactory.autowirebeanproperties (Goo, 1, True);
Sure enough
The solution is to add a cached map in the outer layer, to ensure that the singleton, so will lose the script without the advantages of convenient modification logic, so to do a clear map of the function can be triggered manually, can also be timed trigger.
The problem is solved because the development is not well understood in the Spring API implementation.
--------------------------
Thanks for having you all the way
Troubleshooting JVM Memory Growth issues