This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push: new b8819c3 Allow for path length in cached resource size b8819c3 is described below commit b8819c3d137007b3f2957aa83eee4bbdd7e65a38 Author: Mark Thomas <ma...@apache.org> AuthorDate: Mon Oct 5 19:05:57 2020 +0100 Allow for path length in cached resource size Based on PR #368 --- java/org/apache/catalina/webresources/CachedResource.java | 4 ++++ webapps/docs/changelog.xml | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/java/org/apache/catalina/webresources/CachedResource.java b/java/org/apache/catalina/webresources/CachedResource.java index db4c6d5..ea15590 100644 --- a/java/org/apache/catalina/webresources/CachedResource.java +++ b/java/org/apache/catalina/webresources/CachedResource.java @@ -414,6 +414,10 @@ public class CachedResource implements WebResource { // case but it makes tracking the current cache size easier. long getSize() { long result = CACHE_ENTRY_SIZE; + // Longer paths use a noticeable amount of memory so account for this in + // the cache size. The fixed component of a String instance's memory + // usage is accounted for in the 500 bytes above. + result += getWebappPath().length() * 2; if (getContentLength() <= objectMaxSizeBytes) { result += getContentLength(); } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 37185e9..57077e9 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -106,6 +106,11 @@ options to enable reflection required by the memory leak prevention / detection code. (markt) </add> + <fix> + When estimating the size of a resource in the static resource cache, + include a specific allowance for the path to the resource. Based on a + pull request by blueSky1825821. (markt) + </fix> </changelog> </subsection> <subsection name="Coyote"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org