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

If a TP instance is not collected it keeps very large amounts of state alive #6410

Closed
dsyme opened this issue Apr 1, 2019 · 0 comments
Closed

Comments

@dsyme
Copy link
Contributor

dsyme commented Apr 1, 2019

We have observed in traces related to #6409 that if a TP instance is not collected then it keeps very large amounts of state alive.

This can happen when:

  1. TP instances have mistakenly kept themselves alive by F# compiler not disposing them correctly
  2. If a TP registers itself in global state, e.g. in a callback in a file watch timer or stores itself in global state in its own DLL
  3. if a TP saves one of its generated ProvidedTypeDefinition in a global cache in its own DLL

Regarding (1) - Obviously if there are compiler bugs we should fix them, but (2) and (3) are also real possibilities.

In these cases, the TP holds an invalidation callback object in its Invalidate event. This invalidation callback should not keep compiler state such as IncrementalBuilder and TcImports alive if it is otherwise eligible for GC.

One defensive coding strategy is to add a weak reference at the callback.

This is a reasonable step for reducing the impact of coding mistakes in type providers.

Repro steps

Repro would involve creating a bad type provider that saves the TP instance into global state.

  • Operating system
  • Branch
  • .NET Runtime, CoreCLR or Mono Version
  • Editing Tools (e.g. Visual Studio Version)
  • Links to F# RFCs or entries on https://github.com/fsharp/fslang-suggestions
  • Links to performance testing scripts
  • Indications of severity
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

No branches or pull requests

1 participant