com.sleepycat.je.dbi
Class MemoryBudget

java.lang.Object
  extended bycom.sleepycat.je.dbi.MemoryBudget
All Implemented Interfaces:
EnvConfigObserver

public class MemoryBudget
extends Object
implements EnvConfigObserver

MemoryBudget calculates the available memory for JE and how to apportion it between cache and log buffers. It is meant to centralize all memory calculations. Objects that ask for memory budgets should get settings from this class, rather than using the configuration parameter values directly.


Field Summary
static int ARRAY_ITEM_OVERHEAD
           
static int BIN_FIXED_OVERHEAD
           
static int BYTE_ARRAY_OVERHEAD
           
static int CHECKPOINT_REFERENCE_SIZE
           
static int DBIN_FIXED_OVERHEAD
           
static int DIN_FIXED_OVERHEAD
           
static int HASHMAP_ENTRY_OVERHEAD
           
static int HASHMAP_OVERHEAD
           
static int HASHSET_ENTRY_OVERHEAD
           
static int HASHSET_OVERHEAD
           
static int IN_FIXED_OVERHEAD
           
static int KEY_OVERHEAD
           
static int LN_OVERHEAD
           
static int LOCK_OVERHEAD
           
static int LOCKINFO_OVERHEAD
           
static int LONG_OVERHEAD
           
static int LSN_SIZE
           
static int OBJECT_OVERHEAD
           
static int TWOHASHMAPS_OVERHEAD
           
static int TXN_OVERHEAD
           
 
Constructor Summary
(package private) MemoryBudget(EnvironmentImpl envImpl, DbConfigManager configManager)
           
 
Method Summary
 long accumulateNewUsage(IN in, long newSize)
           
 void envConfigUpdate(DbConfigManager configManager)
          Respond to config updates.
 long getBINOverhead()
           
 long getCacheMemoryUsage()
           
 long getDBINOverhead()
           
 long getDINOverhead()
           
 long getINOverhead()
           
 long getLogBufferBudget()
           
 long getMaxMemory()
           
static long getRuntimeMaxMemory()
          Returns Runtime.maxMemory(), accounting for a MacOS bug.
 long getTreeBudget()
           
(package private)  void initCacheMemoryUsage()
          Initialize the starting environment memory state
(package private)  void loadStats(StatsConfig config, EnvironmentStats stats)
           
 void refreshCacheMemoryUsage(long newSize)
           
 void updateCacheMemoryUsage(long increment)
          Update the environment wide count, wake up the evictor if necessary.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LONG_OVERHEAD

public static final int LONG_OVERHEAD
See Also:
Constant Field Values

BYTE_ARRAY_OVERHEAD

public static final int BYTE_ARRAY_OVERHEAD
See Also:
Constant Field Values

OBJECT_OVERHEAD

public static final int OBJECT_OVERHEAD
See Also:
Constant Field Values

ARRAY_ITEM_OVERHEAD

public static final int ARRAY_ITEM_OVERHEAD
See Also:
Constant Field Values

HASHMAP_OVERHEAD

public static final int HASHMAP_OVERHEAD
See Also:
Constant Field Values

HASHMAP_ENTRY_OVERHEAD

public static final int HASHMAP_ENTRY_OVERHEAD
See Also:
Constant Field Values

HASHSET_OVERHEAD

public static final int HASHSET_OVERHEAD
See Also:
Constant Field Values

HASHSET_ENTRY_OVERHEAD

public static final int HASHSET_ENTRY_OVERHEAD
See Also:
Constant Field Values

TWOHASHMAPS_OVERHEAD

public static final int TWOHASHMAPS_OVERHEAD
See Also:
Constant Field Values

LN_OVERHEAD

public static final int LN_OVERHEAD
See Also:
Constant Field Values

BIN_FIXED_OVERHEAD

public static final int BIN_FIXED_OVERHEAD
See Also:
Constant Field Values

DIN_FIXED_OVERHEAD

public static final int DIN_FIXED_OVERHEAD
See Also:
Constant Field Values

DBIN_FIXED_OVERHEAD

public static final int DBIN_FIXED_OVERHEAD
See Also:
Constant Field Values

IN_FIXED_OVERHEAD

public static final int IN_FIXED_OVERHEAD
See Also:
Constant Field Values

KEY_OVERHEAD

public static final int KEY_OVERHEAD
See Also:
Constant Field Values

LSN_SIZE

public static final int LSN_SIZE
See Also:
Constant Field Values

LOCK_OVERHEAD

public static final int LOCK_OVERHEAD
See Also:
Constant Field Values

LOCKINFO_OVERHEAD

public static final int LOCKINFO_OVERHEAD
See Also:
Constant Field Values

TXN_OVERHEAD

public static final int TXN_OVERHEAD
See Also:
Constant Field Values

CHECKPOINT_REFERENCE_SIZE

public static final int CHECKPOINT_REFERENCE_SIZE
See Also:
Constant Field Values
Constructor Detail

MemoryBudget

MemoryBudget(EnvironmentImpl envImpl,
             DbConfigManager configManager)
       throws DatabaseException
Method Detail

envConfigUpdate

public void envConfigUpdate(DbConfigManager configManager)
                     throws DatabaseException
Respond to config updates.

Specified by:
envConfigUpdate in interface EnvConfigObserver
Throws:
DatabaseException

getRuntimeMaxMemory

public static long getRuntimeMaxMemory()
Returns Runtime.maxMemory(), accounting for a MacOS bug. May return Long.MAX_VALUE if there is no inherent limit. Used by unit tests as well as by this class.


initCacheMemoryUsage

void initCacheMemoryUsage()
                    throws DatabaseException
Initialize the starting environment memory state

Throws:
DatabaseException

updateCacheMemoryUsage

public void updateCacheMemoryUsage(long increment)
Update the environment wide count, wake up the evictor if necessary.

Parameters:
increment - note that increment may be negative.

accumulateNewUsage

public long accumulateNewUsage(IN in,
                               long newSize)

refreshCacheMemoryUsage

public void refreshCacheMemoryUsage(long newSize)

getCacheMemoryUsage

public long getCacheMemoryUsage()

getLogBufferBudget

public long getLogBufferBudget()

getMaxMemory

public long getMaxMemory()

getTreeBudget

public long getTreeBudget()

getINOverhead

public long getINOverhead()

getBINOverhead

public long getBINOverhead()

getDINOverhead

public long getDINOverhead()

getDBINOverhead

public long getDBINOverhead()

loadStats

void loadStats(StatsConfig config,
               EnvironmentStats stats)


Copyright 2004 Sleepycat, Inc. All Rights Reserved.