Skip to content

next: free the xe memory region query after each poll - #2209

Merged
flightlessmango merged 1 commit into
flightlessmango:masterfrom
anaveto:fix/xe-drm-query-leak
Nov 15, 2026
Merged

flightlessmango merged 1 commit into
flightlessmango:masterfrom
anaveto:fix/xe-drm-query-leak

Conversation

@anaveto

@anaveto anaveto commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

xe_drm_base::poll() gets DRM_XE_DEVICE_QUERY_MEM_REGIONS into a buffer from xe_device_query_alloc_fetch() (calloc). poll() does not free that buffer. The GPU thread calls poll() 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 a std::vector and does not leak.

Testing:

build heap in use before → after 10,000 polls per poll
master 77,104 → 1,197,104 bytes +112 bytes
this PR 77,104 → 77,104 bytes 0 bytes

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

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>
@anaveto
anaveto marked this pull request as ready for review November 15, 2026 03:06
@flightlessmango
flightlessmango merged commit 199227b into flightlessmango:master Nov 15, 2026
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.

2 participants