Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: out of memory issue due to accumulation of items in ScanContext #103

Merged
merged 7 commits into from
May 2, 2024

Conversation

plusvic
Copy link
Member

@plusvic plusvic commented May 2, 2024

ScanContext contains hash maps that tracks the matches found for each pattern. The values in these maps are vectors that can become very large. For performance reasons, instead of completely deallocating those vectors after each scan, we were clearing the vector but retaining its capacity, so that they can be reused in later scans. The problem with that is that these vectors are not freed while the scanner is in use, and this can have a large impact on the process' memory footprint, causing OOM issues.

This PR adds a PatternMatches type that encapsulates all the logic for tracking pattern matches, including a more sophisticated approach that tries to reuse the vectors as much as possible, but frees them when they grow too much.

@plusvic plusvic enabled auto-merge (squash) May 2, 2024 12:00
@plusvic plusvic merged commit 7093a31 into main May 2, 2024
24 checks passed
@plusvic plusvic deleted the oom branch May 2, 2024 13:11
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