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

REngine does not Dispose correctly #143

Open
aschwenker-insight opened this issue Jun 18, 2021 · 0 comments
Open

REngine does not Dispose correctly #143

aschwenker-insight opened this issue Jun 18, 2021 · 0 comments

Comments

@aschwenker-insight
Copy link

I am using R.NET 1.9.0 with .NET Framework 4.8 and R 4.1.0.

Given the following code:

REngine.SetEnvironmentVariables();
using (var engine1 = REngine.GetInstance())
{
  //Do something
}

using(var engine2 = REngine.GetInstance())
{
  //Do something else
}

This code should execute successfully as engine1 is disposed before engine2 is created.

Instead the result is an InvalidOperationException with the message The single REngine instance has already been disposed of (i.e. shut down). Multiple engine restart is not possible.

This is occurring because the internal engine field within REngine is not being set to null during the Dispose(bool disposing) method.

Is this by design?

As a workaround, I am treating REngine as a singleton within my application but I believe I should be able to dispose and recreate it repeatedly.

My issue is occurring within an Azure Function that wraps an R library and loads an REngine for each request for isolation between calls.

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