Too many &
and |
patterns cause Visual Studio/Ionide to use up all available memory
#15086
Labels
Area-Compiler-Checking
Type checking, attributes and all aspects of logic checking
Bug
Impact-Medium
(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Regression
Theme-Performance
Milestone
Opening a file with too many
&
and nested|
patterns (inside of a single match branch?) causes Visual Studio or Ionide to use up all available memory and can eventually cause Windows to crash. It will continue to use up more and more memory even if you remove enough patterns to be under the "too many" threshold or close the file. More repetitions of this type of pattern will increase the rate at which memory is consumed.Repro steps
This is likely not a perfectly minimal repro, but maybe it's good enough to hint at what the problem might be.
Write code that uses a fair number of
&
and nested|
patterns inside of a single pattern-matching branch.This is not enough to cause a problem1:
This, however, is (the number of repetitions required to trigger the behavior is not exact; it's somewhere between the examples above and below):
You will notice faster consumption of memory if you add more repetitions.
Visual Studio will eventually use up all available memory without further interaction. I have not let total memory usage go beyond 99% before killing VS, but a coworker's Windows machine eventually crashed on him when he did.
Expected behavior
I expect Visual Studio/Code not to use up all of my computer's memory—and certainly not gradually, in the background, without additional interaction.
Actual behavior
Visual Studio/Code uses up all of my computer's memory.
Known workarounds
None.
Related information
Both Visual Studio 17.5.4 and Visual Studio Code 1.77.3 + Ionide 7.5.2 on Windows 10 and 11.
Footnotes
This is a simplified example. The real code where we first ran into this bug did not actually repeat identical matches. ↩
The text was updated successfully, but these errors were encountered: