1
Vote

Memory Leak when using AppDomains

description

Hello,

There is a leak when running the engine in another AppDomain.
I created a very simple program to reproduce that (see attachment).

To create the leak, pass true to the CreateEngine function. That way it will use an AppDomain.
Using TaskManager and other tools you'll see the memory increase, then it will throw an OutOfMemoryException.

Passing it false tells it to use the same AppDomain as the application and will not leak.

Tested with IronPython 2.7.1 and 2.7.3.

file attachments

comments

MarkusSchaber wrote Oct 26, 2012 at 11:46 AM

Hello,

It seems you don't unload your AppDomains. You need to explicitly unload it when it is not needed any more.

See http://msdn.microsoft.com/de-de/library/system.appdomain.unload.aspx for more information.

HTH,
Markus

Loupi wrote Oct 26, 2012 at 1:46 PM

Markus,

This really does not explain why memory goes up and up and it's never released ONLY when using an AppDomain. In my opinion, unloading the AppDomain is a band-aid solution that does not solve the real problem at its root. Also, I really do not want to allocate an AppDomain per running script.

I want to use a single ScriptEngine, associated with an AppDomain, that runs multiple scripts. And I think it was designed this way.

Now imagine that i have a single ScriptEngine, running multiple scripts in parallel, each in it's own thread. Continuously. I always need the AppDomain to live in this situation. Monitoring memory to schedule an AppDomain unload looks also very ugly to me.