Should I clear unused javascript arrays? -


i'm working on page that, eventually, have more 100 arrays, few of used @ given time.

at moment, i'm populating arrays global variables, suspect inefficient in terms of memory use.

should change code clear arrays when not being used? if so, best way this? i'd guess var myarray = new array() perhaps there's better option.

unless have many thousands of objects in arrays, don't need worry. don't prematurely optimize code; browser quite @ handling lots of small objects.

if memory become issue or notice performance issues, can reassign new array variables:

myarray = []; 

the garbage collector clean objects dereferenced.

in broader case, if there's no need keep references objects, don't need arrays begin with. i.e., if never access elements put in arrays second time, remove arrays , don't bother assigning data.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -