MM, VBS, Memory Management and Performance

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

Moderators: Gurus, Addon Administrators

halcinlatsmir
Posts: 13
Joined: Fri Sep 24, 2010 2:32 pm

MM, VBS, Memory Management and Performance

Post by halcinlatsmir »

Hi,

I was wondering if there are any memory issues or implications I should consider when coding. EG: Is there a garbage collection routine? Would repeatedly creating/destroying certain MemVars/Objects slow performance?

Example 1:

Code: Select all

Dim objSongData

Sub SaveTrack (objSongList)
	If objSonglist.Count > 0 then
		For SongKey = 0 to objSonglist.Count -1
			Set objSongData = objSonglist.Item(SongKey)
			' blah
		Next
	End If
End Sub
Example 2:

Code: Select all

Sub SaveTrack (objSongList)
	Dim objSongData
	
	If objSonglist.Count > 0 then
		For SongKey = 0 to objSonglist.Count -1
			Set objSongData = objSonglist.Item(SongKey)
			' blah
		Next
	End If
End Sub
Example 3:

Code: Select all

Sub SaveTrack (objSongList)
	If objSonglist.Count > 0 then
		For SongKey = 0 to objSonglist.Count -1
			Dim objSongData
			
			Set objSongData = objSonglist.Item(SongKey)
			' blah
		Next
	End If
End Sub
Is there any difference to the way MM & VBS would handle the above three examples? I'm assuming Dim scopes objSongData to the file/addon, Sub, For-Next-Loop respectively. This would mean running Example 3 would involve objSonData being created/destroyed many times, but is that a good idea? Would my addon end up slowly increasing MM's Memory usage or slow performance as objSongData is repeatedly created/destroyed?

Are there any implications when using array/table/list/hash type MemVars?
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: MM, VBS, Memory Management and Performance

Post by trixmoto »

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.
Post Reply