I’m curious, and I’m sure I could set up a GC test, but figured before doing that I’d ask the forums:
Let’s say I have a utility class that contains a static method. This method runs some math on the arguments passed to it, then returns an Array.
Example:
// within the utility class
public static function getPoints(num:Number):Array {
var ar:Array = [];
/// some math here
return ar;
}
// this would be invoked/utilized in another class as:
var pts:Array = UtilClass.getPoints(1234);
Question - does the variable pts retain reference to the array within the static method? I know arrays reference other arrays unless you use concat or something similar - but since the array is declared within the static method, when it returns that array should I use the following instead to make sure references aren’t kept and everything is getting Garbage Collected?
// within the utility class
public static function getPoints(num:Number):Array {
var ar:Array = [];
/// some math here
return ar;
}
// this would be invoked in another class as:
var pts:Array = [];
pts = pts.concat(UtilClass.getPoints(1234));