Changeset 393
- Timestamp:
- 08/04/10 18:11:40 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
kahina/trunk/src/org/kahina/core/io/magazine/ObjectMagazine.java
r390 r393 23 23 import org.kahina.core.util.ProgressMonitorWrapper; 24 24 25 /** 26 * Stores objects in memory by default, but serializes them away to disk in 27 * blocks when memory usage exceeds a specified threshold. The idea is from 28 * {@url http://forums.sun.com/thread.jspa?messageID=10949277#10949277}. 29 * @author ke 30 * 31 * @param <S> 32 */ 25 33 public class ObjectMagazine<S> 26 34 { 27 private static final boolean VERBOSE = false;35 private static final boolean VERBOSE = true; 28 36 29 37 private final File folder; … … 124 132 ns = System.nanoTime(); 125 133 } 134 // TODO Comparing memory usage to the lower bound doesn't really 135 // make sense, the VM will keep all the garbage lying around. Maybe 136 // just reduce to a fixed number of blocks (like 10) and explicitly 137 // garbage-collect then. 126 138 while (blockNumbersUnloadQueue.size() > 1 && memoryRatio() > lowerBound) 127 139 { … … 138 150 private float memoryRatio() 139 151 { 140 return ((float) runtime.totalMemory()) / Math.min(runtime.maxMemory(), runtime.freeMemory()); 152 if (VERBOSE) 153 { 154 System.err.println("Total memory: " + runtime.totalMemory()); 155 System.err.println("Max memory: " + runtime.maxMemory()); 156 System.err.println("Free memory: " + runtime.freeMemory()); 157 System.err.println("Ratio: " + ((float) (runtime.totalMemory() - runtime.freeMemory())) / runtime.maxMemory()); 158 } 159 return ((float) (runtime.totalMemory() - runtime.freeMemory())) / runtime.maxMemory(); 141 160 } 142 161
