Using Active Scripting from within C# without leaking memory

Working for about 3 days to get rid of memory leaks when using Microsoft’s Active Scripting from within a C# .NET 2.0 Windows Forms application, I finally managed to create a working example project that runs without memory leaks.

Download example project (VS 2008) with source and binary files

I used Red Gate’s ANTS Memory Profiler to verify for memory leaks, the best tool around for doing such a task.

The key in resolving (see download project) was to call IActiveScript::Close to free any resources.

I hope, this article will help someone in the future when facing a similar issue.

(References: My initial question on Stack Overflow)

One thought on “Using Active Scripting from within C# without leaking memory

  1. Ludvig says:


    I have tried the enclosed code/Project, but it seems to use more and more memory for each click on “Run Script”. Is that not a memory leak?


Leave a Reply

Your email address will not be published. Required fields are marked *