Author: remm
Date: Tue Nov 28 16:30:07 2006
New Revision: 480302

URL: http://svn.apache.org/viewvc?view=rev&rev=480302
Log:
- 41057: Caching large strings uses too much memory and is a bit pointless, so 
add an upper bound to the String length.

Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/buf/StringCache.java

Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/buf/StringCache.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/buf/StringCache.java?view=diff&rev=480302&r1=480301&r2=480302
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/buf/StringCache.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/buf/StringCache.java Tue 
Nov 28 16:30:07 2006
@@ -56,7 +56,11 @@
         
Integer.parseInt(System.getProperty("tomcat.util.buf.StringCache.cacheSize", 
"200"));
     
 
-    /**
+    protected static int maxStringSize = 
+        
Integer.parseInt(System.getProperty("tomcat.util.buf.StringCache.maxStringSize",
 "128"));
+    
+
+   /**
      * Statistics hash map for byte chunk.
      */
     protected static HashMap bcStats = new HashMap(cacheSize);
@@ -210,7 +214,7 @@
         // still training
         if (bcCache == null) {
             String value = bc.toStringInternal();
-            if (byteEnabled) {
+            if (byteEnabled && (value.length() < maxStringSize)) {
                 // If training, everything is synced
                 synchronized (bcStats) {
                     // If the cache has been generated on a previous invocation
@@ -324,7 +328,7 @@
         // still training
         if (ccCache == null) {
             String value = cc.toStringInternal();
-            if (charEnabled) {
+            if (charEnabled && (value.length() < maxStringSize)) {
                 // If training, everything is synced
                 synchronized (ccStats) {
                     // If the cache has been generated on a previous invocation



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to