I was wondering something, I use a lot of extension requests, for starting to shoot the gun, when jumping, triggering items, etc lots and lots.
So there's a lot of allocations for the SFSObject like this (from your BattleFarm exemple)
Code: Select all
var paramsObj:SFSObject = new SFSObject();
paramsObj.putInt("bId", i);
paramsObj.putInt("bx", px);
paramsObj.putInt("by", py);
refDocument.smartFox.send(new ExtensionRequest("bb", paramsObj));
The same thing happens when sending user variables such as this:
Code: Select all
if(m_PlayerPawn.m_vLocation.X != m_fNetPawnLocationX)
m_UserVars.push(new SFSUserVariable("PosX", m_PlayerPawn.m_vLocation.X, VariableType.DOUBLE));
if(m_PlayerPawn.m_vLocation.Y != m_fNetPawnLocationY)
m_UserVars.push(new SFSUserVariable("PosY", m_PlayerPawn.m_vLocation.Y, VariableType.DOUBLE));
Isn't that worrying with the constant allocating and the garbage collector? Every list of things to do to optimize your game includes cutting down on the constant object allocations like that. I was thinking of reusing the same SFSObject and just create it once but there's no "clear" method to remove all its keys or anything. It would be tedious to remove the specific named keys (still doable). In the case of user variable maybe i could keep an instance for it and change its values I think? Would that even work? What are your thoughts on the best way to go about reducing allocations on that front?
Thank you very much