hlsf wrong slicing solving
This commit is contained in:
@@ -25,18 +25,8 @@
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using Microsoft.Win32;
|
||||
|
||||
using StgSharp.Threading;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using hlsfHandle = StgSharp.HighPerformance.Memory.HybridLayerSegregatedFitAllocationHandle;
|
||||
|
||||
@@ -121,13 +111,15 @@ namespace StgSharp.HighPerformance.Memory
|
||||
current->NextNear = newEntry;
|
||||
next->PreviousNear = newEntry;
|
||||
|
||||
newEntry->Level = i;
|
||||
PushLevel(i, Math.Min(blockCount - 1, 2), bucket);
|
||||
|
||||
// set new entry
|
||||
// Entry* old = current;
|
||||
current = newEntry;
|
||||
|
||||
newEntry->Level = i;
|
||||
PushLevel(i, Math.Min(blockCount - 1, 2), bucket);
|
||||
|
||||
// Console.WriteLine($"{(ulong)current->PreviousNear}<->{(ulong)current->NextNear},\t{current->Size}");
|
||||
|
||||
finalOffset += (ulong)s;
|
||||
remainSize -= (ulong)s;
|
||||
if (remainSize <= (ulong)levelSize)
|
||||
@@ -212,6 +204,8 @@ namespace StgSharp.HighPerformance.Memory
|
||||
// Entry* old = current;
|
||||
current = newEntry;
|
||||
|
||||
// Console.WriteLine($"{(ulong)current->PreviousNear}<->{(ulong)current->NextNear},\t{current->Size}");
|
||||
|
||||
// update lock and data
|
||||
finalOffset += (ulong)s;
|
||||
remainSize -= (ulong)s;
|
||||
@@ -225,6 +219,8 @@ namespace StgSharp.HighPerformance.Memory
|
||||
{
|
||||
e->Size = (uint)(offset);
|
||||
e->Level = GetLevelFromSize((uint)offset);
|
||||
|
||||
// Console.WriteLine("Alloc ok");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,7 +237,6 @@ namespace StgSharp.HighPerformance.Memory
|
||||
{
|
||||
nuint pos = _spareMemory->Position;
|
||||
nuint blockSize = (nuint)levelSizeArray[^1] * 2; // Use last level size (16MB)
|
||||
nuint newPos = pos + blockSize;
|
||||
|
||||
Entry* previous;
|
||||
previous = _spareMemory->PreviousNear;
|
||||
@@ -250,6 +245,7 @@ namespace StgSharp.HighPerformance.Memory
|
||||
handle = null;
|
||||
return false; // No spare memory available
|
||||
}
|
||||
nuint newPos = pos + blockSize;
|
||||
|
||||
// Check if we have enough space
|
||||
if (newPos > ((nuint)m_Buffer) + _size)
|
||||
@@ -270,8 +266,6 @@ namespace StgSharp.HighPerformance.Memory
|
||||
BucketNode* b = (BucketNode*)handle->Position;
|
||||
b->EntryRef = handle;
|
||||
|
||||
// PushLevel(handle->Level, DetermineSegmentIndex((uint)blockSize, handle->Level), b);
|
||||
|
||||
// update position linked list
|
||||
handle->NextNear = _spareMemory;
|
||||
handle->PreviousNear = previous;
|
||||
|
||||
Reference in New Issue
Block a user