You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by gr...@locus.apache.org on 2000/11/19 21:38:52 UTC
cvs commit: xml-cocoon/src/org/apache/cocoon/store MemoryStore.java
greenrd 00/11/19 12:38:52
Modified: . changes.xml
src/org/apache/cocoon cocoon.properties
src/org/apache/cocoon/store MemoryStore.java
Log:
more aggressive store cleanup
Revision Changes Path
1.149 +4 -0 xml-cocoon/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/xml-cocoon/changes.xml,v
retrieving revision 1.148
retrieving revision 1.149
diff -u -r1.148 -r1.149
--- changes.xml 2000/11/16 23:44:36 1.148
+++ changes.xml 2000/11/19 20:38:51 1.149
@@ -4,7 +4,7 @@
<!--
History of Cocoon changes
- $Id: changes.xml,v 1.148 2000/11/16 23:44:36 greenrd Exp $
+ $Id: changes.xml,v 1.149 2000/11/19 20:38:51 greenrd Exp $
-->
<changes title="History of Changes">
@@ -18,6 +18,10 @@
</devs>
<release version="@version@" date="@date@">
+ <action dev="RDG" type="fix">
+ Made store cleanup algorithm more aggressive. Hopefully this should clear
+ up some of the OutOfMemoryErrors people have been having.
+ </action>
<action dev="RDG" type="fix" due-to="Mike Ehlers"
due-to-email="maehlers@hewitt.com">
Workaround for an AbstractMethodError bug on some JDKs.
1.43 +18 -10 xml-cocoon/src/org/apache/cocoon/cocoon.properties
Index: cocoon.properties
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/cocoon.properties,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- cocoon.properties 2000/11/10 14:13:26 1.42
+++ cocoon.properties 2000/11/19 20:38:52 1.43
@@ -297,12 +297,17 @@
# the default cache
cache = org.apache.cocoon.cache.CocoonCache
-# disable page caching
+#uncomment this to disable ALL page caching
#cache = org.apache.cocoon.cache.NoCache
-#Change this to false to disable Last-Modified headers
+#Change this to false to disable all Last-Modified headers
+#This will also disable client-side and proxy caching, but not Cocoon
+#internal caching.
+#Content that is not cached by Cocoon will not have a Last-Modified header.
lastmodified = true
+#NOTE: See also the next set of options. The CocoonCache is implemented by
+#the Store.
##########################################
# Object Storage Systems #
@@ -312,22 +317,25 @@
store = org.apache.cocoon.store.MemoryStore
# Indicates how much free memory should always be available to the JVM. (in bytes)
+# Here, 10M.
store.freememory = 1000000
-# Indicates the sleeping time for the background thread (in seconds)
-#store.interval = 10
+# Indicates the sleeping time for the background checking thread (in seconds)
+store.interval = 10
# Indicates the thread priority (1-10: 10 is maximum, 1 is minimum)
-#store.threadpriority = 10
+store.threadpriority = 10
-# Uncomment this to disable the background thread that manages the cache
-# overflow and leave this at request time.
+# Uncomment this to disable the background thread that manages the store
+# overflow.
+# WARNING: Disabling this may result in intermittent OutOfMemoryErrors.
#store.usethread = false
-# Indicates what is the maximum heap size that your JVM can reach (in bytes)
-# This is normally set using the -mx or -Xmx command line argument.
-store.heapsize = 60000000
+# Soft maximum heap size. Cocoon will try to aggressively flush its store
+# to stay not too far above this limit.
+# To change the absolute maximum, consult your JDK tool documentation.
# here, 60M or close to it anyway
+store.heapsize = 60000000
1.14 +13 -4 xml-cocoon/src/org/apache/cocoon/store/MemoryStore.java
Index: MemoryStore.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/store/MemoryStore.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- MemoryStore.java 2000/11/01 20:12:28 1.13
+++ MemoryStore.java 2000/11/19 20:38:52 1.14
@@ -1,4 +1,4 @@
-/*-- $Id: MemoryStore.java,v 1.13 2000/11/01 20:12:28 greenrd Exp $ --
+/*-- $Id: MemoryStore.java,v 1.14 2000/11/19 20:38:52 greenrd Exp $ --
============================================================================
The Apache Software License, Version 1.1
@@ -67,7 +67,7 @@
*
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
* @author <a href="mailto:michel.lehon@outwares.com">Michel Lehon</a>
- * @version $Revision: 1.13 $ $Date: 2000/11/01 20:12:28 $
+ * @version $Revision: 1.14 $ $Date: 2000/11/19 20:38:52 $
*/
public class MemoryStore implements Store, Status, Configurable, Runnable {
@@ -161,11 +161,17 @@
*/
public void run() {
while (true) {
- if (this.jvm.totalMemory() > this.heapsize) {
+
+ // RDG (2000/11/19): Changed the algorithm to free store entries when EITHER
+ // the heap is too big or the free RAM is too small, rather than both having to be
+ // true as was previously the case. This is more intuitive and more forgiving
+ // of configuration mistakes.
+
+ if (memoryLow ()) {
this.jvm.runFinalization();
this.jvm.gc();
synchronized (this) {
- while ((this.hashtable.size() > 0) && (this.jvm.freeMemory() < this.freememory)) {
+ while ((this.hashtable.size() > 0) && memoryLow ()) {
this.free();
}
}
@@ -177,6 +183,9 @@
}
}
+ public boolean memoryLow () {
+ return jvm.totalMemory () > heapsize || jvm.freeMemory () < freememory;
+ }
/**
* Store the given object in a persistent state. It is up to the
@@ -314,7 +323,7 @@
buffer.append("Daemon thread check interval: "+ this.interval +"<br>");
}
buffer.append("Minimum required free memory: " + this.freememory + "<br>");
- buffer.append("Minimum heap size: " + this.heapsize + "<br>");
+ buffer.append("Soft maximum heap size: " + this.heapsize + "<br>");
buffer.append("Current free memory: " + this.jvm.freeMemory() + "<br>");
buffer.append("Current heap size: " + this.jvm.totalMemory() + "<br><ul>");
Enumeration e = list();
@@ -326,4 +335,4 @@
buffer.append("</ul>");
return buffer.toString();
}
-}
\ No newline at end of file
+}