Groups | Blog | Home
all groups > dotnet vsa > august 2003 >

dotnet vsa : VsaEngine.Compile() increases memory usage by a minimum of 1/4 meg?


boogs
8/26/2003 2:19:59 PM
Hi,

I'm aware of the various problems with not being able to reclaim memory used
by the Compile() method in VSA. However, it seems like the minimum memory
used by that operation is quite high.

Here the code to a simple console app. Every time runScript() is executed
the memory used (according to task manager) increased by about 250k. Is
there anything I can do to decrease the memory this operation requires?

========================================================

using System;
using Microsoft.JScript.Vsa;
using Microsoft.JScript;
using Microsoft.Vsa;

namespace ConsoleApplication1
{
class Class1 : IVsaSite, IMessageReceiver
{
private static string printOutput;

[STAThread]
static void Main(string[] args)
{
while (true)
{
Console.ReadLine();
runScript("print(" + DateTime.Now.Millisecond + ")");
}
}

private static string runScript(string source)
{
VsaEngine engine = new VsaEngine(false);
Class1 site = new Class1();

printOutput = "";
engine.RootMoniker = "test://test";
engine.Site = site;
engine.InitNew();
IVsaCodeItem cItem = (IVsaCodeItem)engine.Items.CreateItem("source",
VsaItemType.Code, VsaItemFlag.Module);
cItem.SourceText = source;
engine.RootNamespace = "foobar";
engine.SetOption("print", true);
engine.Compile();
engine.Run();

return printOutput;
}

public void Message(string strValue)
{
printOutput += strValue + " ";
}

public object GetEventSourceInstance(string itemName, string
eventSourceName)
{}
public object GetGlobalInstance(string name)
{}
public void Notify(string notify, object info)
{}
public bool OnCompilerError(IVsaError error)
{}
public void GetCompiledState(out byte[] pe, out byte[] debugInfo)
{}
}
}

Jim Bob
8/29/2003 2:56:19 PM
add the following line in your run script method..

engine.GenerateDebugInfo = false;


[quoted text, click to view]

boogs
8/29/2003 8:44:39 PM
[quoted text, click to view]

Jim --

Thank-you for replying. Unfortunately, adding that line decreases the memory
consuption by only a few kb.

For the time being, I've decided to roll my own script engine with the
CodeDOM classes. The memory consumption is not much different, however I can
make my scripts into classes and then reuse them in a thread-safe way, which
makes a big difference for our app.

--
Aaron

AddThis Social Bookmark Button