COM memory leak - 20/01/17 03:13 PM
I'm not sure if its mIRC or the interface I'm using, but something is leaking memory. The following code creates an instance of window's jscript engine, executes a function and dispatches the returned object.
When the identifying mIRC com is closed, the memory consumed by the dispatch com isn't freed:
More Info:
When the identifying mIRC com is closed, the memory consumed by the dispatch com isn't freed:
Code:
;; /LeakTest <amount_of_times_to_call_function> alias leaktest { var %x = $$1, %error var %js = (function(){return{"test":Array(3001).join("a")}})() .comopen LeakTest MSScriptControl.ScriptControl if (!$com(LeakTest)) || ($comerr) { %Error = SCRIPTCONTROL_INIT_FAIL } elseif (!$com(LeakTest, language, 4, bstr, jscript)) || ($comerr) { %Error = LANGUAGE_SET_FAIL } else { while (%x) { dec %x ;; Dispatches the result of the js function, but then immediately closes it ;; yet the memory isn't freed even if given time if (!$com(LeakTest, eval, 1, bstr, %Js, dispatch* LeakTest/Test) || $comerr || !$com(LeakTest/Test)) { %Error = failed to dispatch LeakTest/Test goto error } .comclose LeakTest/Test } } :error if ($com(LeakTest/Test)) .comclose $v1 if ($com(LeakTest)) .comclose $v1 if ($error || %error) { Echo -a ERROR: $v1 } else { echo -a Done! } }
More Info:
Code:
//echo -a $os $version $beta $md5($mircexe,2) $file($mircexe).sig $alias(0) $script(0) $dll(0) $com(0) 10 7.47 7fbdee41d89a9a06431e08d52aa7f49b ok 1 1 0 0