Update of /cvsroot/jrobin/src/org/jrobin/core
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21479/org/jrobin/core
Modified Files:
RrdNioBackend.java
Log Message:
rrdrestore command supported
Index: RrdNioBackend.java
===================================================================
RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdNioBackend.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** RrdNioBackend.java 12 Jul 2004 13:35:16 -0000 1.9
--- RrdNioBackend.java 13 Jul 2004 11:45:39 -0000 1.10
***************
*** 37,40 ****
--- 37,52 ----
*/
public class RrdNioBackend extends RrdFileBackend {
+ /**
+ * Defines if the <code>System.gc()</code> method should be executed when the backend is closed.
+ * NIO backend uses large in-memory buffer to cache file data. The buffer remains 'active'
+ * (by prohibiting file re-creation, for example) as long as it is not garbage collected.
+ * By forcing <code>gc()</code> after the file is closed memory gets freed sooner and file
+ * re-creation won't fail.<p>
+ *
+ * The constant is set to false initially and currently there is no API to change it
+ * during runtime.<p>
+ */
+ public static final boolean SHOULD_GC_AFTER_CLOSE = false;
+
private static final Timer syncTimer = new Timer(true);
***************
*** 104,112 ****
*/
public void close() throws IOException {
if(syncTask != null) {
syncTask.cancel();
}
! super.close(); // calls sync()
byteBuffer = null;
}
--- 116,130 ----
*/
public void close() throws IOException {
+ // cancel synchronization
if(syncTask != null) {
syncTask.cancel();
}
! super.close(); // calls sync() eventually
! // release the buffer, make it eligible for GC as soon as possible
byteBuffer = null;
+ if(SHOULD_GC_AFTER_CLOSE) {
+ // I am not happy with this, but it might be necessary in the future
+ System.gc();
+ }
}
|