public IndexPopulationJob(MultipleIndexPopulator multiPopulator, IndexingService.Monitor monitor, bool verifyBeforeFlipping) { this._multiPopulator = multiPopulator; this._monitor = monitor; this._verifyBeforeFlipping = verifyBeforeFlipping; this._memoryAllocationTracker = new ThreadSafePeakMemoryAllocationTracker(GlobalMemoryTracker.INSTANCE); this._bufferFactory = new ByteBufferFactory(() => new UnsafeDirectByteBufferAllocator(_memoryAllocationTracker), parseBlockSize()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDeallocateAllAllocatedMemoryOnDrop() throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldDeallocateAllAllocatedMemoryOnDrop() { // given ThreadSafePeakMemoryAllocationTracker memoryTracker = new ThreadSafePeakMemoryAllocationTracker(new LocalMemoryTracker()); ByteBufferFactory bufferFactory = new ByteBufferFactory(() => new UnsafeDirectByteBufferAllocator(memoryTracker), 100); BlockBasedIndexPopulator <GenericKey, NativeIndexValue> populator = InstantiatePopulator(NO_MONITOR, bufferFactory); bool closed = false; try { // when //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.Collection<org.neo4j.kernel.api.index.IndexEntryUpdate<?>> updates = batchOfUpdates(); ICollection <IndexEntryUpdate <object> > updates = BatchOfUpdates(); populator.Add(updates); int nextId = updates.Count; ExternalUpdates(populator, nextId, nextId + 10); nextId = nextId + 10; long memoryBeforeScanCompleted = memoryTracker.UsedDirectMemory(); populator.ScanCompleted(nullInstance); ExternalUpdates(populator, nextId, nextId + 10); // then assertTrue("expected some memory to have been temporarily allocated in scanCompleted", memoryTracker.PeakMemoryUsage() > memoryBeforeScanCompleted); populator.Drop(); closed = true; assertEquals("expected all allocated memory to have been freed on drop", memoryBeforeScanCompleted, memoryTracker.UsedDirectMemory()); bufferFactory.Close(); assertEquals(0, memoryTracker.UsedDirectMemory()); } finally { if (!closed) { populator.Close(true); } } }