Skip to content

fix(core): cache X-Client-Info header per client assembly - #548

Merged
Tr00d merged 1 commit into
masterfrom
fix-excessive-GC-allocation
Oct 26, 2026
Merged

Tr00d merged 1 commit into
masterfrom
fix-excessive-GC-allocation

Conversation

@Tr00d

@Tr00d Tr00d commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Fixes #523.

Problem

Util.GetAssemblyVersion builds the X-Client-Info header from scratch on every call, and most clients call it once per request. Each build scans every loaded assembly. On Unity it also reads the custom attributes of every assembly, which accounted for most of the 32 MB in the report (#523).

Fix

Cache the header in a ConcurrentDictionary keyed by the client assembly. The first call per client builds it; later calls return the cached string with no allocation.

The header value is unchanged, and so is the public API.

@Tr00d
Tr00d merged commit 731e1f8 into master Oct 26, 2026
3 checks passed
@Tr00d
Tr00d deleted the fix-excessive-GC-allocation branch October 26, 2026 06:24
@FozerG

FozerG commented Oct 26, 2026

Copy link
Copy Markdown

That's so good! Thank you 😉

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.

Excessive GC allocations on every request in Unity

2 participants