garbage collection - delete ref to object in array javascript -
say have code:
var players = []; function player(){ var num = players.length; } players.push(new player()); //player
can delete player memory? example:
players.splice(0, 1);
will garbage collector collect player after this?
i recommend taking @ deleting objects in javascript, when should use delete vs setting elements null in javascript? , memory management (nice reference, @karthick).
since javascript garbage collected, don't need delete objects - removed when there no way refer them anymore.
you can, however, delete reference object once you're it's been used:
it can useful delete references object if finished them, because gives garbage collector more information able reclaimed.
however in general taken care of , if hit edge case should not performance problem in small scale applications.
Comments
Post a Comment