Add ability to downsize caches in response to a max-memory signal #443
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Make FCS automatically downsize caches when a maximum allocated memory threshold memory is reached.
This is somewhat experimental but may be the best solution to the "Visual Studio grinds to a complete halt" issue discussed here: fsprojects-archive/zzarchive-VisualFSharpPowerTools#1160 (comment)
The default threshold is 1.7GB of allocated managed memory in a process. This corresponds to a managed memory size of around 2.5GB. When this happens, the "strong" values for keeping background project builds are reduced to size 1 for the remainder of the lifetime of the FSharpChecker object. In practice this will still make Visual Studio F# Power Tools usable, but some operations like renaming across multiple projects may take longer.
Reducing the FCS strong cache sizes does not guarantee there will be enough memory to continue operations - even holding one project strongly may exceed a process memory budget. It just means FCS may hold less memory strongly.