Skip to content

Forward readSafe in BinaryReadStream.GetMemory - #23

Open
Illustar0 wants to merge 1 commit into
Noggog:devfrom
Illustar0:fix/get-memory-read-safe
Open

Illustar0 wants to merge 1 commit into
Noggog:devfrom
Illustar0:fix/get-memory-read-safe

Conversation

@Illustar0

Copy link
Copy Markdown

BinaryReadStream.GetMemory wasn't forwarding readSafe to ReadMemory(amount), so it always defaulted to readSafe: true and allocated a new byte[] on every call even when the caller explicitly passed readSafe: false.

While profiling Mutagen, this accounted for nearly all of the ~95 MB allocated during a single-plugin FrameWalk (~110 B per record) and ~200 MB of the 266 MB allocated during load order scanning.

- Pass the readSafe parameter to ReadMemory in both GetMemory overloads
- Avoid allocating a new byte array when readSafe is false and sufficient bytes remain in the internal buffer
@Illustar0

Copy link
Copy Markdown
Author

Mutagen-Modding/Mutagen#749 should be merged before or together with this PR.

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