You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: MemoryManager.Core/AllocatorStrategy.cs
+9Lines changed: 9 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,9 @@
8
8
9
9
namespaceMemoryManager.Core
10
10
{
11
+
/// <summary>
12
+
/// Enum for possible allocation strategies. This is used to determine which lane to use for a given allocation request, and can be configured globally or per-allocation.
13
+
/// </summary>
11
14
publicenumAllocatorStrategy
12
15
{
13
16
/// <summary>
@@ -21,5 +24,11 @@ public enum AllocatorStrategy
21
24
/// Absolute maximum speed, requires frequent compactions
22
25
/// </summary>
23
26
LinearBump=1,
27
+
28
+
/// <summary>
29
+
/// The slab lane,
30
+
/// Uses fixed-size bins for small allocations, excellent for uniform patterns, but can lead to fragmentation if misused.
Copy file name to clipboardExpand all lines: README.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,6 +50,11 @@ To move this system out of the prototyping phase and into a hardened, production
50
50
***Current State:** When compaction triggers, the compactor engine allocates an entirely new unmanaged heap block via `Marshal.AllocHGlobal` and slides all survivors over via memory block copying. For massive heaps (e.g., 512MB+), this causes noticeable block stutters (latency spikes) and temporarily forces a **double memory footprint**.
51
51
***Production Fix:** Implement an **Incremental/Phased Compactor** that only relocates a small chunk of fragmented blocks per frame tick, or enforce strict zero-compaction rules where arenas are completely cleared and cycled out at deterministic boundaries (e.g., scene changes).
52
52
53
+
### 3. Add bool IsFragmented() to trigger Compact() on threshold
54
+
*** Current State:** The compactor is only triggered when the arena is completely full. This allows fragmentation to grow unchecked until the last possible moment, causing more severe stutters and higher memory usage.
55
+
***Production Fix:** Introduce an `IsFragmented()` method that evaluates the current fragmentation level against a predefined threshold. If the fragmentation exceeds the threshold, trigger the `Compact()` method proactively to maintain optimal memory usage and reduce latency spikes.
0 commit comments