https://bz.apache.org/bugzilla/show_bug.cgi?id=66178
Bug ID: 66178 Summary: Garbage from strings in AbstractArchiveResourceSet.getResource Product: Tomcat 8 Version: 8.5.x-trunk Hardware: Macintosh Status: NEW Severity: normal Priority: P2 Component: Catalina Assignee: dev@tomcat.apache.org Reporter: midnjack...@gmail.com Target Milestone: ---- Created attachment 38343 --> https://bz.apache.org/bugzilla/attachment.cgi?id=38343&action=edit possible patch to reduce garbage If you have a large-ish number of jars (something like 1200 in my case) then we end up calling the getResource method of AbstractArchiveResourceSet for each jar every time that we load a new resource. This code does a few substrings and string concatenation that ends up generating a lot of garbage due to the fact that it's called constantly. This happens even if the resource is cached because of the code in Cache.getResource() If the entry is found in the cache we call it here if (cacheEntry != null && !cacheEntry.validateResource(useClassLoaderResources)) { Using JFR to capture some profiling data I was able to see that replacing the string concatenation with a StringBuilder reduced the garbage by about 3x - 4x. In the original, it created something like 20 mb when loading a page that serves multiple resources and after the change, it only allocated about 7 mb. Attached is a git patch showing a possible fix. I'd be happy to make a PR as well. -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org