protected internal OffHeapNumberArray(long length, int itemSize, long @base, MemoryAllocationTracker allocationTracker) : base(itemSize, @base) { UnsafeUtil.assertHasUnsafe(); this.LengthConflict = length; this.AllocationTracker = allocationTracker; long dataSize = length * itemSize; bool itemSizeIsPowerOfTwo = Integer.bitCount(itemSize) == 1; if (UnsafeUtil.allowUnalignedMemoryAccess || !itemSizeIsPowerOfTwo) { // we can end up here even if we require aligned memory access. Reason is that item size // isn't power of two anyway and so we have to fallback to safer means of accessing the memory, // i.e. byte for byte. _allocatedBytes = dataSize; this._allocatedAddress = this.Address = UnsafeUtil.allocateMemory(_allocatedBytes, allocationTracker); } else { // the item size is a power of two and we're required to access memory aligned // so we can allocate a bit more to ensure we can get an aligned memory address to start from. _allocatedBytes = dataSize + itemSize - 1; this._allocatedAddress = UnsafeUtil.allocateMemory(_allocatedBytes, allocationTracker); this.Address = UnsafeUtil.alignedMemory(_allocatedAddress, itemSize); } }
internal static long GetVictimPage(int pageSize, MemoryAllocationTracker allocationTracker) { lock (typeof(VictimPageReference)) { if (_victimPageSize < pageSize) { // Note that we NEVER free any old victim pages. This is important because we cannot tell // when we are done using them. Therefor, victim pages are allocated and stay allocated // until our process terminates. _victimPagePointer = UnsafeUtil.allocateMemory(pageSize, allocationTracker); _victimPageSize = pageSize; } return(_victimPagePointer); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void freeFrozenMemory() internal virtual void FreeFrozenMemory() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.memory.MemoryAllocationTracker memoryTrackerSpy = spy(new org.neo4j.memory.LocalMemoryTracker()); MemoryAllocationTracker memoryTrackerSpy = spy(new LocalMemoryTracker()); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final MutableLinearProbeLongHashSet set2 = new MutableLinearProbeLongHashSet(new OffHeapMemoryAllocator(memoryTrackerSpy, blockAllocator)); MutableLinearProbeLongHashSet set2 = new MutableLinearProbeLongHashSet(new OffHeapMemoryAllocator(memoryTrackerSpy, _blockAllocator)); verify(memoryTrackerSpy).allocated(anyLong()); set2.AddAll(100, 200, 300); set2.Freeze(); set2.Remove(100); set2.Freeze(); set2.Clear(); set2.Close(); verify(memoryTrackerSpy, times(3)).deallocated(anyLong()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void allocateFreeMemory() internal virtual void AllocateFreeMemory() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.memory.MemoryAllocationTracker memoryTrackerSpy = spy(new org.neo4j.memory.LocalMemoryTracker()); MemoryAllocationTracker memoryTrackerSpy = spy(new LocalMemoryTracker()); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final MutableLinearProbeLongHashSet set2 = new MutableLinearProbeLongHashSet(new OffHeapMemoryAllocator(memoryTrackerSpy, blockAllocator)); MutableLinearProbeLongHashSet set2 = new MutableLinearProbeLongHashSet(new OffHeapMemoryAllocator(memoryTrackerSpy, _blockAllocator)); verify(memoryTrackerSpy).allocated(anyLong()); for (int i = 0; i < DEFAULT_CAPACITY; i++) { set2.Add(100 + i); } verify(memoryTrackerSpy).deallocated(anyLong()); verify(memoryTrackerSpy, times(2)).allocated(anyLong()); set2.Close(); verify(memoryTrackerSpy, times(2)).deallocated(anyLong()); }
protected internal OffHeapByteArray(long length, sbyte[] defaultValue, long @base, MemoryAllocationTracker allocationTracker) : base(length, defaultValue.Length, @base, allocationTracker) { this._defaultValue = defaultValue; Clear(); }
internal TestMemoryAllocator(MemoryAllocationTracker tracker) { this.Tracker = tracker; }
public LongKeyLongValueUnsafeTable(int capacity, MemoryAllocationTracker allocationTracker) : base(capacity, 16, new long[1], allocationTracker) { }
protected internal OffHeapRegularNumberArray(long length, int shift, long @base, MemoryAllocationTracker allocationTracker) : base(length, 1 << shift, @base, allocationTracker) { this.Shift = shift; }
public IntKeyUnsafeTable(int capacity, VALUE valueMarker, MemoryAllocationTracker allocationTracker) : base(capacity, 4, valueMarker, allocationTracker) { }
public static PrimitiveLongSet OffHeapLongSet(int initialCapacity, MemoryAllocationTracker allocationTracker) { return(new PrimitiveLongHashSet(new LongKeyUnsafeTable <object>(initialCapacity, ValueMarker, allocationTracker), ValueMarker, NO_MONITOR)); }
public static PrimitiveLongSet OffHeapLongSet(MemoryAllocationTracker allocationTracker) { return(OffHeapLongSet(DefaultOffheapCapacity, allocationTracker)); }
public static PrimitiveIntSet OffHeapIntSet(MemoryAllocationTracker allocationTracker) { return(new PrimitiveIntHashSet(new IntKeyUnsafeTable <object>(DefaultOffheapCapacity, ValueMarker, allocationTracker), ValueMarker, NO_MONITOR)); }
public static PrimitiveLongLongMap OffHeapLongLongMap(int initialCapacity, MemoryAllocationTracker allocationTracker) { return(new PrimitiveLongLongHashMap(new LongKeyLongValueUnsafeTable(initialCapacity, allocationTracker), NO_MONITOR)); }
public OffHeapLongArray(long length, long defaultValue, long @base, MemoryAllocationTracker allocationTracker) : base(length, 3, @base, allocationTracker) { this._defaultValue = defaultValue; Clear(); }