Page 1 of 2

ActiveX Browser Memory Leak

Posted: Mon Jan 11, 2010 1:29 pm
by CarlitoGil
I create a window with a browser, when opened and closed repeatedly I notice the memory consumption is too high

I created a script to illustrate the problem, It uses a timer to close and reopen the window, watch your windows task manager

How do I completely destroy the browser when the window is closed?

Change the URL if you like, even to a local file

Code: Select all


###### Scripts.ini ######

[TestLeak]
Filename=TestLeak.vbs
Procname=TestLeak
DisplayName=Test Leak
Order=100
ScriptType=0
Language=VBScript
Description=Testing
Shortcut=Shift+Q



###### TestLeak.vbs ######

Option Explicit

Sub TestLeak()

	Dim Timer, Form, WB

	Set Timer = SDB.CreateTimer(2000)
	Script.RegisterEvent Timer, "OnTimer", "TestLeakTimer"
	
	Set Form = SDB.Objects("TestLeakWindow")
	Set WB = SDB.Objects("TestLeakWebBrowser")
		
	If Not (WB Is Nothing) Then
		WB.Common.DestroyControl
		Set WB = Nothing  
		Set SDB.Objects("TestLeakWebBrowser") = Nothing
		If (Form.Common.Visible) Then Exit Sub
	End If

	If Not (Form Is Nothing) Then
		If Not (Form.Common.Visible) Then Script.UnregisterEvents Timer
		Script.UnregisterEvents Form
		Form.Common.Visible = False
		Form.Common.ControlName = ""
		Set Form = Nothing  
		Set SDB.Objects("TestLeakWindow") = Nothing
		Exit Sub
	End If
	
	Set Form = SDB.UI.NewForm
	Form.Common.SetRect 50, 50, 600, 400
	Form.Common.MinWidth = 400
	Form.Common.MinHeight = 300
	Form.FormPosition = 4
	Form.StayOnTop = False
	Form.Caption = "Test Leak"
	Form.Common.ControlName = "TestLeak"

	Set WB = SDB.UI.NewActiveX(Form, "Shell.Explorer")
	WB.Common.Align = 5
	WB.Common.ControlName = "WB"

	SDB.Objects("TestLeakWindow") = Form
	SDB.Objects("TestLeakWebBrowser") = WB
	
	WB.Interf.Navigate "google.com"

	Form.Common.Visible = True

End Sub

Sub TestLeakTimer(Timer)

	Script.UnregisterEvents Timer
	Call TestLeak()
	
End Sub

Re: ActiveX Browser Memory Leak

Posted: Mon Jan 11, 2010 6:51 pm
by trixmoto
Have you tried DestroyControl?

BTW. You're missing a close bracket in your "TestLeakTimer" sub.

Tried DestroyControl, doesn't seem to work

Posted: Mon Jan 11, 2010 8:28 pm
by CarlitoGil
MMWiki says DestroyControl is only for browsers and references a search script, so maybe it only works on that type of script

This script demonstrates that it does destroy the control, but the memory keeps climbing up.

Did I implement this right?

(Edit: added DestroyControl to the script and fixed bracket)

Re: ActiveX Browser Memory Leak

Posted: Tue Jan 12, 2010 6:03 am
by trixmoto
I've not actually used it before, but yes that's certainly how I would have thought it should be implemented. I think this is going to have to be one for the devs to answer.

Caramba!

Posted: Tue Jan 12, 2010 6:17 am
by CarlitoGil
Was afraid of that

Let's hope it's not a really a bug

Thanks anyway, you and this forum are always helpful.
Should I repost somewhere else?

Re: ActiveX Browser Memory Leak

Posted: Tue Jan 12, 2010 1:40 pm
by trixmoto
I noticed that you posted this in the bug section as well...

http://www.mediamonkey.com/forum/viewto ... =7&t=45911

Re: ActiveX Browser Memory Leak

Posted: Thu Jan 14, 2010 5:24 am
by Ludek

Re: ActiveX Browser Memory Leak

Posted: Thu Jan 14, 2010 6:43 am
by Ludek
GIL,
I tested by using your script and I cannot reproduce.

Everytime the timer hits memory usage grows up, but then (as expected) tails off.

So I don't see a leak there, are you sure you have tested 3.2.1.1294 ?

Re: ActiveX Browser Memory Leak

Posted: Thu Jan 14, 2010 6:53 am
by CarlitoGil
Ludek wrote:3.2.1.1294
No,
I've got 3.2.0.1294

Re: ActiveX Browser Memory Leak

Posted: Thu Jan 14, 2010 6:56 am
by CarlitoGil
The ActiveX browser is pretty much the same as the installed IE, so could it be something ticked there?
I don't have many extras on my IE, I don't use it much, no bars or anything but are you using Windows 7 x64?

Re: ActiveX Browser Memory Leak

Posted: Thu Jan 14, 2010 7:04 am
by Ludek
Sorry, I meant 3.2.0.1294, of course.

I also thought it could be something related to IE.

I have tested it on Win XP SP2. I am rebooting to Windows 7.

Re: ActiveX Browser Memory Leak

Posted: Thu Jan 14, 2010 7:14 am
by CarlitoGil
I just fired it up in VMware, Windows XP Pro x86, MM 1294
It doesn't built up either, so it has something to do with Windows 7 or IE8.

Re: ActiveX Browser Memory Leak

Posted: Thu Jan 14, 2010 7:29 am
by Ludek
Rebooted to Windows 7 and true is that there is 3 MB leak and it seems to be a leak in Win 7 IE.
Maybe it isn't a leak, just Win 7 caches a data for next use of IE, because after several attempts (say 3) the memory usage stays at the same level and doesn't grow anymore.

Probably nothing we could fix.

Re: ActiveX Browser Memory Leak

Posted: Thu Jan 14, 2010 7:36 am
by CarlitoGil
In my case it will fill my memory up,
goes on and on

Re: ActiveX Browser Memory Leak

Posted: Thu Jan 14, 2010 7:39 am
by CarlitoGil
wait, 3?
You mean open and close the window 3 times?

Because that's too little, just leave it there literally a couple o minutes