Changeset 395

Show
Ignore:
Timestamp:
08/04/10 22:01:29 (2 years ago)
Author:
ke
Message:

Reverted changes from revision 394, keeping a minimal amount of blocks around is not a good idea, we run into memory limits quicker than expected. Set upper memory usage bound from 0.6 to 0.9 to give automatic garbage collection a chance to free up resources before blocks are serialized away.

Files:

Legend:

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

    r394 r395  
    3535        private static final boolean VERBOSE = true; 
    3636         
    37         private static final int MIN_BLOCKS = 10; // TODO make configurable 
     37        private static final int MIN_BLOCKS = 1; 
    3838 
    3939        private final File folder; 
     
    4141        private final int blockSize; 
    4242 
    43         private final float lowerBound; // TODO use or abolish 
     43        private final float lowerBound; 
    4444 
    4545        private final float upperBound; 
     
    134134                                ns = System.nanoTime(); 
    135135                        } 
    136                         while (blockNumbersUnloadQueue.size() > MIN_BLOCKS) 
     136                        // TODO Comparing memory usage to the lower bound doesn't really 
     137                        // make sense, the VM will keep all the garbage lying around. Maybe 
     138                        // just reduce to a fixed number of blocks (like 10) and explicitly 
     139                        // garbage-collect then. 
     140                        while (blockNumbersUnloadQueue.size() > MIN_BLOCKS && memoryRatio() > lowerBound) 
    137141                        { 
    138142                                unloadBlock(blockNumbersUnloadQueue.removeFirst()); 
    139143                        } 
    140                         System.gc(); 
    141144                        if (VERBOSE) 
    142145                        { 
     
    196199        public static <S> ObjectMagazine<S> create() 
    197200        { 
    198                 return create(1000, 0.2F, 0.6F); 
     201                return create(1000, 0.2F, 0.9F); 
    199202        } 
    200203