/// <summary> /// This method will re-arrange the array in a way that /// all the used memory is contiguous when possible. /// </summary> /// <param name="limitSwaps">Limits the number of chunk swaps for a partial defragmentation.</param> /// <param name="movedCallback">Callback invoked on each swap.</param> public override void Defrag(int limitSwaps = int.MaxValue, Action <MemoryPointer> movedCallback = null) { Action <MemoryPointer> callback = (chunk) => { BufferResource resource = chunk as BufferResource; // - Invalidate the moved resource resource.Invalidate(true); movedCallback?.Invoke(chunk); }; base.Defrag(limitSwaps, callback); }
/// <summary> /// Reserve a heap's chunk and returns a pointer to this area. /// </summary> /// <param name="size">Number of bytes to reserve.</param> /// <returns>An handle to the reserved area.</returns> public override MemoryPointer Alloc(uint size) { BufferResource resource = new BufferResource(this, size); return(base.Alloc(resource)); }