Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1386635 #17

Merged
merged 1 commit into from
Oct 22, 2021

Conversation

nosami
Copy link
Member

@nosami nosami commented Oct 22, 2021

FCS contains the following method

    member _.CheckMaxMemoryReached() =
        if not maxMemoryReached && GC.GetTotalMemory(false) > int64 maxMB * 1024L * 1024L then
            Trace.TraceWarning("!!!!!!!! MAX MEMORY REACHED, DOWNSIZING F# COMPILER CACHES !!!!!!!!!!!!!!!")
            // If the maxMB limit is reached, drastic action is taken
            //   - reduce strong cache sizes to a minimum
            maxMemoryReached <- true
            braceMatchCache.Resize(AnyCallerThread, newKeepStrongly=10)
            backgroundCompiler.DownsizeCaches()
            maxMemEvent.Trigger( () )

On the surface, this looks fine, but on Mono, GC.GetTotalMemory can be
slow and it is called repeatedly.

Set maxMemoryReached via reflection to short circuit this code (which always
returns false anyway due to high maxMB setting)

FCS contains the following method

```fs
    member _.CheckMaxMemoryReached() =
        if not maxMemoryReached && GC.GetTotalMemory(false) > int64 maxMB * 1024L * 1024L then
            Trace.TraceWarning("!!!!!!!! MAX MEMORY REACHED, DOWNSIZING F# COMPILER CACHES !!!!!!!!!!!!!!!")
            // If the maxMB limit is reached, drastic action is taken
            //   - reduce strong cache sizes to a minimum
            maxMemoryReached <- true
            braceMatchCache.Resize(AnyCallerThread, newKeepStrongly=10)
            backgroundCompiler.DownsizeCaches()
            maxMemEvent.Trigger( () )

```

On the surface, this looks fine, but on Mono GC.GetTotalMemory can be
slow and it is called repeatedly.

Set maxMemoryReached via reflection to short circuit this code (which always
returns false anyway due to high maxMB setting)
@nosami nosami merged commit 6bea628 into fsharp-editor Oct 22, 2021
@nosami nosami deleted the dev/nosami/fix-1386635 branch October 22, 2021 13:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant