Skip to content

Scope split-mode graph mmap to the tensor being loaded. Prevents memory leak#2126

Draft
Farmadupe wants to merge 1 commit into
ikawrakow:mainfrom
Farmadupe:fix_parallel_load_leak
Draft

Scope split-mode graph mmap to the tensor being loaded. Prevents memory leak#2126
Farmadupe wants to merge 1 commit into
ikawrakow:mainfrom
Farmadupe:fix_parallel_load_leak

Conversation

@Farmadupe

@Farmadupe Farmadupe commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

#2102 introduced a change where staging buffers for tensor reads were swapped from anonymous memory to mmaped memory. For some reason (read: "I failed at devibing the prototype") these allocations were freed using llama_mmap::dontneed_fragment which delegates to posix MADV_DONTNEED instead of just letting them drop out of scope

llama_mmap::dontneed_fragment is a no-op on windows and this caused memory pressure and a regression in model load times.

Fix is to let the mmaps drop out of scope. This also removes the need for the windows workaround introduced in #2121, as this fixes the issue at the root cause.

The change is complete but I will flip to ready once I have tested on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant