Changeset 394

Show
Ignore:
Timestamp:
08/04/10 20:11:03 (2 years ago)
Author:
ke
Message:

Changed object magazine strategy: when memory usage exceeds the upper bound, the number of blocks is reduced to a fixed amount (10), then a garbage collection is requested to prevent memory usage to hit the upper bound again immediately. The old strategy of reducing until memory usage subceeds the lower bound would only work if we were prepared to request a garbage collection after serializing away each block.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • kahina/trunk/src/org/kahina/core/io/magazine/ObjectMagazine.java

    r393 r394  
    3434{ 
    3535        private static final boolean VERBOSE = true; 
     36         
     37        private static final int MIN_BLOCKS = 10; // TODO make configurable 
    3638 
    3739        private final File folder; 
     
    3941        private final int blockSize; 
    4042 
    41         private final float lowerBound; 
     43        private final float lowerBound; // TODO use or abolish 
    4244 
    4345        private final float upperBound; 
     
    132134                                ns = System.nanoTime(); 
    133135                        } 
    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. 
    138                         while (blockNumbersUnloadQueue.size() > 1 && memoryRatio() > lowerBound) 
     136                        while (blockNumbersUnloadQueue.size() > MIN_BLOCKS) 
    139137                        { 
    140138                                unloadBlock(blockNumbersUnloadQueue.removeFirst()); 
    141139                        } 
     140                        System.gc(); 
    142141                        if (VERBOSE) 
    143142                        {