IronLanguages / IronLanguages/ironpython3
how can i release Scope when i reuse ScriptEngine
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2.8k
- Forks
- 316
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 1
Description
Prerequisites
The issue tracker is used to report bugs and request new features, NOT to ask questions.
Questions should be posted to the users mailing list which can be accessed at
https://ironpython.groups.io/g/users.
- [* ] Are you running the latest version?
- Are you reporting to the correct repository?
- Did you perform a cursory search?
Description
ScriptEngine engine = Python.CreateEngine();
ScriptSource scriptSource= engine.CreateScriptSourceFromString(script);
var _compiledCode = scriptSource.Compile();
follow i only create and compile one engine;
and then multi run method in a thread with a new Scope;
public class MyThread
{
public ScriptEngine engine { set; get; }
public ScriptSource sourceCode { set; get; }
public string name { set; get; }
public void scriptProc()
{
ScriptScope scope = engine.CreateScope();
scope.SetVariable("number", 10);
scope.SetVariable("name", name);
var result = sourceCode.Execute<object>(scope);
var SetAddress = scope.GetVariable<object>("number");
Console.WriteLine(Thread.CurrentThread.Name+"--->"+SetAddress);
cutDown();
}
}
Question:
- how to release Scope ,to avoid out of memory!
which Just like a WebApiController,create a new Scope for each request,and then release it after completely.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ScriptEngine.CreateScope, ScriptScope.SetVariable, and ScriptSource.Execute entry points shown in the issue, and determine the intended lifetime of a scope created per thread or request. The issue provides no target file or test; done would require a clear, maintainable answer or project change addressing scope cleanup and potential memory growth.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 15/100