Skip to content

automata: call Vec::shrink_to_fit in a few strategic places#1298

Merged
BurntSushi merged 1 commit intomasterfrom
ag/improve-memory-usage
Sep 23, 2025
Merged

automata: call Vec::shrink_to_fit in a few strategic places#1298
BurntSushi merged 1 commit intomasterfrom
ag/improve-memory-usage

Conversation

@BurntSushi
Copy link
Copy Markdown
Member

Other parts of regex-automata do this implicitly by using Box<[T]>,
btu it's not always straight-forward to use Box<[T]>. (Or, at least,
non-annoying.) In some of those cases here, we call Vec::shrink_to_fit
to decrease memory usage.

These are probably the biggest offenders, but I didn't do a thorough
investigation here.

Fixes #1297

Other parts of `regex-automata` do this implicitly by using `Box<[T]>`,
btu it's not always straight-forward to use `Box<[T]>`. (Or, at least,
non-annoying.) In some of those cases here, we call `Vec::shrink_to_fit`
to decrease memory usage.

These are probably the biggest offenders, but I didn't do a thorough
investigation here.

Fixes #1297
@bobrik
Copy link
Copy Markdown

bobrik commented Sep 23, 2025

Typo: btu -> but, LGTM otherwise.

@BurntSushi BurntSushi merged commit 02a62ba into master Sep 23, 2025
18 checks passed
@BurntSushi BurntSushi deleted the ag/improve-memory-usage branch September 23, 2025 23:14
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.

Extra memory consumption from Vec growth

2 participants