public static synchronized void shutdown() { for (OMMapBufferEntry entry : new ArrayList<OMMapBufferEntry>(bufferPoolLRU)) { entry.close(); } bufferPoolLRU.clear(); bufferPoolPerFile.clear(); totalMemory = 0; }
/** * Removes the file. * * @throws IOException */ public static synchronized void removeFile(final OFile file) throws IOException { final List<OMMapBufferEntry> entries = bufferPoolPerFile.remove(file); if (entries != null) { for (OMMapBufferEntry entry : entries) { bufferPoolLRU.remove(entry); entry.close(); } entries.clear(); } }
/** Flushes away all the buffers of closed files. This frees the memory. */ public static synchronized void flush() { OMMapBufferEntry entry; for (Iterator<OMMapBufferEntry> it = bufferPoolLRU.iterator(); it.hasNext(); ) { entry = it.next(); if (entry.file != null && entry.file.isClosed()) { removeEntry(it, entry); entry.close(); } } }
/** Frees the mmap entry from the memory */ private static boolean removeEntry( final Iterator<OMMapBufferEntry> it, final OMMapBufferEntry entry) { if (commitBuffer(entry)) { // COMMITTED: REMOVE IT it.remove(); final List<OMMapBufferEntry> file = bufferPoolPerFile.get(entry.file); if (file != null) { file.remove(entry); if (file.isEmpty()) bufferPoolPerFile.remove(entry.file); } entry.buffer = null; totalMemory -= entry.size; return true; } return false; }