This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/8.5.x by this push:
     new c1087c8  Allow for path length in cached resource size
c1087c8 is described below

commit c1087c8c880e1b52f7865807a119aee9b741bd3b
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 1bd2ef3..3ea042d 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -84,6 +84,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

Reply via email to