Adobe scout is great profiling tool sometimes is annoying but only in usability wise.

During profiling application life cycle I have found some peeks of GC process. Like here:

bool

Nothing special at quick look, I thought that some uncleaned reference especially that body looks like:

public static function multiplyMatrixVectors(matrix1:Vector.<Number>, matrix2:Vector.<Number>, result:Vector.<Number> = null):Vector.<Number> {
	result ||= new Vector.<Number>(16, true);

	// multiplication code here

	return result;
}

So at first point I ensured myself that in every place I’m using some kind of worker instance of result just to reuse product of this method. It was clear. But GC problem still exits.

After that I started undermine statement “instance ||= new Instance()” And I thought that maybe in some case ‘new’ operator is called even if condition is not fulfilled. Quick trace inside TestClass. And it’s not called. That’s OK. But problem exists.

I did lucky shot, and I changed it to:

public static function multiplyMatrixVectors(matrix1:Vector.<Number>, matrix2:Vector.<Number>, result:Vector.<Number> = null):Vector.<Number> {
	if(!result) result = new Vector.<Number>(16, true);

	// multiplication code here

	return result;
}

Problem has gone!

if

But wait. Why?

I checked deasembled code and it looks exactly the same:

public static function multiplyMatrixVectors(param1:Vector.<Number>, param2:Vector.<Number>, param3:Vector.<Number> = null) : Vector.<Number>
   {
      if(!param3)
      {
         param3 = new Vector.<Number>(16,true);
      }
      // multiplication code here
      return param3
   }

There should be some difference. But not in this form. So let’s check ABC code:

IF statement

trait method Qname(PackageNamespace(""),"multiplyMatrixVectors") dispid 0
method
name "multiplyMatrixVectors"
flag HAS_OPTIONAL
flag HAS_OPTIONAL
flag HAS_PARAM_NAMES
param TypeName(Qname(PackageNamespace("__AS3__.vec"),"Vector")<Qname(PackageNamespace(""),"Number")>)
param TypeName(Qname(PackageNamespace("__AS3__.vec"),"Vector")<Qname(PackageNamespace(""),"Number")>)
param TypeName(Qname(PackageNamespace("__AS3__.vec"),"Vector")<Qname(PackageNamespace(""),"Number")>)
paramname "matrix1"
paramname "matrix2"
paramname "result"
optional null
returns TypeName(Qname(PackageNamespace("__AS3__.vec"),"Vector")<Qname(PackageNamespace(""),"Number")>)

body
maxstack 5
localcount 4
initscopedepth 0
maxscopedepth 1

code
getlocal_0
pushscope
getlocal_3
iftrue ofs0015
getlex Qname(PackageNamespace("__AS3__.vec"),"Vector")
getlex Qname(PackageNamespace(""),"Number")
applytype 1
pushbyte 16
pushtrue
construct 2
coerce TypeName(Qname(PackageNamespace("__AS3__.vec"),"Vector")<Qname(PackageNamespace(""),"Number")>)
setlocal_3
ofs0015:getlocal_2

||= statement

trait method Qname(PackageNamespace(""),"multiplyMatrixVectors") dispid 0
method
name "multiplyMatrixVectors"
flag HAS_OPTIONAL
flag HAS_OPTIONAL
flag HAS_PARAM_NAMES
param TypeName(Qname(PackageNamespace("__AS3__.vec"),"Vector")<Qname(PackageNamespace(""),"Number")>)
param TypeName(Qname(PackageNamespace("__AS3__.vec"),"Vector")<Qname(PackageNamespace(""),"Number")>)
param TypeName(Qname(PackageNamespace("__AS3__.vec"),"Vector")<Qname(PackageNamespace(""),"Number")>)
paramname "matrix1"
paramname "matrix2"
paramname "result"
optional null
returns TypeName(Qname(PackageNamespace("__AS3__.vec"),"Vector")<Qname(PackageNamespace(""),"Number")>)

body
maxstack 5
localcount 4
initscopedepth 0
maxscopedepth 1

code
getlocal_0
pushscope
getlocal_3
iftrue ofs0013
getlex Qname(PackageNamespace("__AS3__.vec"),"Vector")
getlex Qname(PackageNamespace(""),"Number")
applytype 1
pushbyte 16
pushtrue
construct 2
setlocal_3
ofs0013:getlocal_2

There is only one difference. When I’m using IF statement there is extra type casting.

coerce TypeName(Qname(PackageNamespace("__AS3__.vec"),"Vector")<Qname(PackageNamespace(""),"Number")>)

That is only one different between 2 swf files. But it influences on GC in some way. Why? because that is in iftrue scope. I have no idea. So far when I have no answer for this I will avoid this (very comfortable) statement.

Environment:

  • AIR SDK 14.0.0
  • Inline: false
  • Compile target Flash Player 14.0
  • Adobe Scout CC 1.1.3
  • FFDEC v.2.1.3

 

 
0 Kudos
Don't
move!