Remove hlsf, TLSF.alloc is ok
This commit is contained in:
@@ -33,6 +33,8 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Tlsf = StgSharp.HighPerformance.Memory.TwoLayerSegregatedFitAllocator;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
internal partial class Program
|
||||
@@ -47,7 +49,7 @@ namespace StgSharp
|
||||
// HLSF test arena
|
||||
Console.WriteLine(
|
||||
"=== HLSF (Hybrid Layer Segregated Fit Allocator) Single-threaded Stress Test ===\n");
|
||||
HybridLayerSegregatedFitAllocator hlsfAllocator = new(size);
|
||||
TwoLayerSegregatedFitAllocator hlsfAllocator = new(size);
|
||||
|
||||
// === 简洁交替测试:100次alloc与100次free交替进行,直到触发异常或达到最大循环 ===
|
||||
Console.WriteLine("\n=== 简洁交替测试:100次alloc + 100次free 交替 ===");
|
||||
@@ -80,7 +82,7 @@ namespace StgSharp
|
||||
Random rnd = new Random(42);
|
||||
for (int round = 1; round <= maxRounds; round++)
|
||||
{
|
||||
List<HlsfHandle> batch = new(maxCount);
|
||||
List<Tlsf.Handle> batch = new(maxCount);
|
||||
for (int i = 0; i < maxCount; i++)
|
||||
{
|
||||
uint sz = sizes[rnd.Next(sizes.Length)];
|
||||
@@ -90,7 +92,7 @@ namespace StgSharp
|
||||
}
|
||||
for (int i = 5; i < maxCount; i += 10)
|
||||
{
|
||||
HlsfHandle origin = batch[i];
|
||||
Tlsf.Handle origin = batch[i];
|
||||
int index = i + offset[rnd.Next(offset.Length)];
|
||||
batch[i] = batch[index];
|
||||
batch[index] = origin;
|
||||
@@ -104,9 +106,10 @@ namespace StgSharp
|
||||
if (round % 100 == 0)
|
||||
{
|
||||
Console.WriteLine($"[交替测试] 已完成 {round} 轮 {maxCount}alloc+{maxCount}free");
|
||||
hlsfAllocator.DumpPositionChain(false, 10);
|
||||
hlsfAllocator.Collect();
|
||||
hlsfAllocator.DumpPositionChain(false, 10);
|
||||
|
||||
// hlsfAllocator.DumpPositionChain(false, 10);
|
||||
// hlsfAllocator.Collect();
|
||||
// hlsfAllocator.DumpPositionChain(false, 10);
|
||||
}
|
||||
}
|
||||
Console.WriteLine("[交替测试] 正常结束,无异常触发");
|
||||
|
||||
Reference in New Issue
Block a user