MM, VBS, Memory Management and Performance

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

Moderator: Gurus

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

MM, VBS, Memory Management and Performance

Post by halcinlatsmir » Mon Feb 24, 2014 9:59 am

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: Barton, UK
Contact:

Re: MM, VBS, Memory Management and Performance

Post by trixmoto » Tue Feb 25, 2014 4:13 am

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.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

Post Reply