Join GitHub today
Clear the GroovyClassLoader cache before compiling #8062
Refactored this after talking with @kimchy, this is now implemented as a listener where the classloader is only cleared when scripts are removed from the cache.
I tested this with the script from #7658 and I was able to send/compile 10,000 unique scripts on both Java 7 and 8 without running into PermGen issues.
Since we don't use the cache, it's okay to clear it entirely if needed, Elasticsearch maintains its own cache for compiled scripts. Adds loader.clearCache() into a listener, the listener is called when a script is removed from the Guava cache. This also lowers the amount of cached scripts to 100, since 500 is around the limit some users have run into before hitting an out of memory error in permgem. Fixes #7658