ActiveX Browser Memory Leak

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey for Windows 4.

Moderators: Gurus, Addon Administrators

CarlitoGil
Posts: 294
Joined: Sun Sep 07, 2008 10:46 am
Location: Dominican Republic
Contact:

ActiveX Browser Memory Leak

Post 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
Last edited by CarlitoGil on Thu Jan 14, 2010 5:31 am, edited 2 times in total.
iTunesMonkey + Acoustid – Find metadata from iTunes and Acoustid
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: ActiveX Browser Memory Leak

Post by trixmoto »

Have you tried DestroyControl?

BTW. You're missing a close bracket in your "TestLeakTimer" sub.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
CarlitoGil
Posts: 294
Joined: Sun Sep 07, 2008 10:46 am
Location: Dominican Republic
Contact:

Tried DestroyControl, doesn't seem to work

Post 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)
Last edited by CarlitoGil on Thu Jan 14, 2010 5:34 am, edited 1 time in total.
iTunesMonkey + Acoustid – Find metadata from iTunes and Acoustid
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: ActiveX Browser Memory Leak

Post 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.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
CarlitoGil
Posts: 294
Joined: Sun Sep 07, 2008 10:46 am
Location: Dominican Republic
Contact:

Caramba!

Post 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?
iTunesMonkey + Acoustid – Find metadata from iTunes and Acoustid
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: ActiveX Browser Memory Leak

Post by trixmoto »

I noticed that you posted this in the bug section as well...

http://www.mediamonkey.com/forum/viewto ... =7&t=45911
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Ludek
Posts: 5114
Joined: Fri Mar 09, 2007 9:00 am

Re: ActiveX Browser Memory Leak

Post by Ludek »

Ludek
Posts: 5114
Joined: Fri Mar 09, 2007 9:00 am

Re: ActiveX Browser Memory Leak

Post 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 ?
CarlitoGil
Posts: 294
Joined: Sun Sep 07, 2008 10:46 am
Location: Dominican Republic
Contact:

Re: ActiveX Browser Memory Leak

Post by CarlitoGil »

Ludek wrote:3.2.1.1294
No,
I've got 3.2.0.1294
iTunesMonkey + Acoustid – Find metadata from iTunes and Acoustid
CarlitoGil
Posts: 294
Joined: Sun Sep 07, 2008 10:46 am
Location: Dominican Republic
Contact:

Re: ActiveX Browser Memory Leak

Post 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?
iTunesMonkey + Acoustid – Find metadata from iTunes and Acoustid
Ludek
Posts: 5114
Joined: Fri Mar 09, 2007 9:00 am

Re: ActiveX Browser Memory Leak

Post 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.
CarlitoGil
Posts: 294
Joined: Sun Sep 07, 2008 10:46 am
Location: Dominican Republic
Contact:

Re: ActiveX Browser Memory Leak

Post 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.
iTunesMonkey + Acoustid – Find metadata from iTunes and Acoustid
Ludek
Posts: 5114
Joined: Fri Mar 09, 2007 9:00 am

Re: ActiveX Browser Memory Leak

Post 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.
CarlitoGil
Posts: 294
Joined: Sun Sep 07, 2008 10:46 am
Location: Dominican Republic
Contact:

Re: ActiveX Browser Memory Leak

Post by CarlitoGil »

In my case it will fill my memory up,
goes on and on
iTunesMonkey + Acoustid – Find metadata from iTunes and Acoustid
CarlitoGil
Posts: 294
Joined: Sun Sep 07, 2008 10:46 am
Location: Dominican Republic
Contact:

Re: ActiveX Browser Memory Leak

Post 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
iTunesMonkey + Acoustid – Find metadata from iTunes and Acoustid
Post Reply