Repository navigation
next: free the xe memory region query after each poll - #2209
Merged
flightlessmango merged 1 commit intoNov 15, 2026
Merged
Conversation
xe_drm_base::poll() fetches DRM_XE_DEVICE_QUERY_MEM_REGIONS into a buffer from xe_device_query_alloc_fetch() and never frees it, so every poll of an Intel xe GPU leaks one query result. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 15, 2026
anaveto
marked this pull request as ready for review
November 15, 2026 03:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
xe_drm_base::poll()getsDRM_XE_DEVICE_QUERY_MEM_REGIONSinto a buffer fromxe_device_query_alloc_fetch()(calloc).poll()does not free that buffer. The GPU thread callspoll()every 500 ms (METRICS_UPDATE_PERIOD_MS), so each Intel xe GPU leaks one query result every 500 ms: 96 bytes for an integrated GPU (one region), 184 bytes for a GPU with VRAM.The change frees the buffer at the end of
poll(). The early return for a failed query has no buffer to free. The i915 path keeps its buffer in astd::vectorand does not leak.Testing:
tools/xe-drm-leak/main.cppon the branch https://github.com/anaveto/MangoHud/tree/test/xe-drm-leak): the program callsxe_drm_base::poll()10,000 times and reads the heap in use (glibcmallinfo2().uordblks) before and after. CI builds the program two times, withxe_drm.cppfrom master (791f920) and from this PR. The two builds differ only in thefree(ptr)line (https://github.com/anaveto/MangoHud/actions/runs/43674541776)./dev/dri/card0, two runs of each build:112 bytes per poll is the 96-byte query result plus the allocator overhead. The GPU thread polls every 500 ms, so master leaks about 800 KB per hour on this GPU.
🤖 model: claude-opus-5-5 | effort: xhigh