-
Notifications
You must be signed in to change notification settings - Fork 150
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
VBScriptEngine.AddHostType memory/handle leak #135
Comments
HI @winkxoe, Can you provide more information? How are you detecting the leak? Do you know what objects are leaked? Thanks! |
I have a application that spins off a new thread every few seconds and
runs a simple VB script using VBScriptEngine. After it's done running
the script it disposes the VBScriptEngine. It also uses AddHostType to
add a class that enables the script to log to the same log file as the
rest of the application. We were using version 5.4.6 for a long time
without any problems. I upgraded to 5.5.6 and the application would grow
to over 9 GB of memory over a 24 hour period and slow the entire server
down. Then I tried 5.6.0 and had the same problem.
Then I did an awful lot of testing to try to isolate the problem. I went
back an tried versions 5.5.3, 5.5.4, and 5.5.5. Versions 5.5.3 and 5.5.4
work fine. Right now we're running 5.5.4 without the application
growing. It was also clear from my testing that it would not grow if I
removed the AddHostType call for the logging class. I tested the
V8ScriptEngine in a similar situation with the same AddHostType call for
the logging class. The application didn't appear to grow with V8.
It's probably not the best practice to create and dispose of so many
instances of the engine. In this case it seems to work for what we need
it for.
I hope this helps! Thank you for supporting ClearScript! It's a
wonderful tool!
From: ClearScript Library [mailto:notifications@github.com]
Sent: Thursday, September 19, 2019 9:44 AM
To: microsoft/ClearScript
Cc: Wineke, Steve; Mention
Subject: Re: [microsoft/ClearScript] VBScriptEngine.AddHostType
memory/handle leak (#135)
HI @winkxoe <https://github.com/winkxoe> ,
Can you provide more information? How are you detecting the leak? Do you
know what objects are leaked?
Thanks!
-
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#135?email_source=notifi
cations&email_token=ANHE72GCJLCUZIH622S7243QKN6YHA5CNFSM4IYA4A42YY3PNVWW
K3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7DQLUY#issuecomment
-533136851> , or mute the thread
<https://github.com/notifications/unsubscribe-auth/ANHE72H5EIQGYN626UIBM
VTQKN6YHANCNFSM4IYA4A4Q> .
|
Hi @winkxoe, A couple of questions:
Thanks! |
I'm using AddHostType(string itemName, SystemType type);
I didn't have to call any methods on the exposed type. I actually
reduced the script to simply setting a string as shown in the example
below and I saw the leak.
Dim nextfile
nextfile = "The very next file"
From: ClearScript Library [mailto:notifications@github.com]
Sent: Friday, September 20, 2019 8:19 AM
To: microsoft/ClearScript
Cc: Wineke, Steve; Mention
Subject: Re: [microsoft/ClearScript] VBScriptEngine.AddHostType
memory/handle leak (#135)
Hi @winkxoe <https://github.com/winkxoe> ,
A couple of questions:
1. Which AddHostType
<https://microsoft.github.io/ClearScript/Reference/html/Overload_Microso
ft_ClearScript_ScriptEngine_AddHostType.htm> overload are you using?
2. Can you reproduce the leak simply by adding the AddHostType
call? Or does it only happen if you call methods on the exposed type
from script code?
Thanks!
-
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#135?email_source=notifi
cations&email_token=ANHE72HH5Q7LCC4K55I4VMTQKS5R5A5CNFSM4IYA4A42YY3PNVWW
K3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7GQG7Y#issuecomment
-533529471> , or mute the thread
<https://github.com/notifications/unsubscribe-auth/ANHE72FJ5BQKJOOIEXLKS
ADQKS5R5ANCNFSM4IYA4A4Q> .
|
Hi @winkxoe, Unfortunately we haven't been able to reproduce your issue so far with ClearScript 5.6.0. In a test program we construct a Can you create a minimal sample program that reproduces the issue? Thanks! |
Can you try this chunk of code? I noticed that if I removed either the
AddHostType or the engine.Script["nextfile"] the leak seemed to go away.
However both of them together and it grows fast.
while (!stop)
{
string text =
"Dim nextfile\n" +
"nextfile = \"The very next file\"";
using (var engine = new VBScriptEngine())
{
engine.AddHostType("Logger", typeof(Console));
engine.Script["nextfile"] = "";
engine.Execute(@text);
}
}
From: ClearScript Library [mailto:notifications@github.com]
Sent: Friday, September 20, 2019 1:01 PM
To: microsoft/ClearScript
Cc: Wineke, Steve; Mention
Subject: Re: [microsoft/ClearScript] VBScriptEngine.AddHostType
memory/handle leak (#135)
Hi @winkxoe <https://github.com/winkxoe> ,
Unfortunately we haven't been able to reproduce your issue so far with
ClearScript 5.6.0. In a test program we construct a VBScriptEngine
instance, expose the Console type, and execute a small script. After
100,000 iterations the program's private memory size is around 12 MB.
Can you create a minimal sample program that reproduces the issue?
Thanks!
-
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#135?email_source=notifi
cations&email_token=ANHE72F4GBXSNOFFNSUR6ATQKT6UDA5CNFSM4IYA4A42YY3PNVWW
K3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7HJVHY#issuecomment
-533633695> , or mute the thread
<https://github.com/notifications/unsubscribe-auth/ANHE72G25JJGUOS3EBVFN
O3QKT6UDANCNFSM4IYA4A4Q> .
|
Thanks for posting the sample code! We've reproduced the issue and will investigate. Cheers! |
Hi @winkxoe, This looks like a bug in COM Interop. We'll have a workaround in the next ClearScript release. In the meantime, you might be able to bypass the issue by replacing this: engine.Script["nextfile"] = ""; with this: engine.Script.nextfile = ""; Good luck! |
Great! Thank you very much! |
…ws (GitHub Issue #9); added support for system documents (GitHub Issue #143); added IList implementation to V8 arrays; added ExtendedHostFunctions.typeLibEnums (GitHub Issue #147); added WindowsScriptEngineFlags.MarshalDateTimeAsDate (GitHub Issue #141); fixed generic type inference for COM interfaces; fixed enumeration of COM collections that don't provide class information (GitHub Issue #146); fixed memory leak impacting Windows Script object property assignment (GitHub Issue #135); updated build and API documentation. Tested with V8 7.9.317.32.
Fixed in ClearScript 6.0. |
It looks like a memory/handle leak was added sometime between versions 5.5.4 and 5.5.5 when calling AddHostTiype from an instance of VBScriptEngine. I think it also affects the JScriptEngine, but not the V8ScriptEngine.
The text was updated successfully, but these errors were encountered: