/** * Initializes common parts of memory and plocal engines if not initialized yet. Does nothing if engines already initialized. */ public void initialize() { if (initialized) return; initialized = true; configureDefaults(); OMemory.checkCacheMemoryConfiguration(); OMemory.fixCommonConfigurationProblems(); }
/** * Checks the OrientDB cache memory configuration and emits a warning if configuration is invalid. */ public static void checkCacheMemoryConfiguration() { final long maxHeapSize = Runtime.getRuntime().maxMemory(); final long maxCacheSize = getMaxCacheMemorySize(); final ONative.MemoryLimitResult physicalMemory = ONative.instance().getMemoryLimit(false); if (maxHeapSize != Long.MAX_VALUE && physicalMemory != null && maxHeapSize + maxCacheSize > physicalMemory.memoryLimit) OLogManager.instance().warnNoDb(OMemory.class, "The sum of the configured JVM maximum heap size (" + maxHeapSize + " bytes) " + "and the OrientDB maximum cache size (" + maxCacheSize + " bytes) is larger than the available physical memory size " + "(" + physicalMemory + " bytes). That may cause out of memory errors, please tune the configuration up. Use the " + "-Xmx JVM option to lower the JVM maximum heap memory size or storage.diskCache.bufferSize OrientDB option to " + "lower memory requirements of the cache."); }
/** * Tries to fix some common cache/memory configuration problems: <ul> <li>Cache size is larger than direct memory size.</li> * <li>Memory chunk size is larger than cache size.</li> <ul/> */ public static void fixCommonConfigurationProblems() { long diskCacheSize = OGlobalConfiguration.DISK_CACHE_SIZE.getValueAsLong(); final int max32BitCacheSize = 512; if (getJavaBitWidth() == 32 && diskCacheSize > max32BitCacheSize) { OLogManager.instance() .infoNoDb(OGlobalConfiguration.class, "32 bit JVM is detected. Lowering disk cache size from %,dMB to %,dMB.", diskCacheSize, max32BitCacheSize); OGlobalConfiguration.DISK_CACHE_SIZE.setValue(max32BitCacheSize); } }
final long jvmMaxMemory = OMemory.getCappedRuntimeMaxMemory(2L * 1024 * 1024 * 1024 /* 2GB */); OLogManager.instance().infoNoDb(this, "JVM can use maximum %dMB of heap memory", jvmMaxMemory / (1024 * 1024));