Skip to content

Tamarin part II – More on Array and Vector

Read Part I

Size in memory:

Start a flash app with

var a:Vector.<int> = new Vector.<int>(1024 * 1024);

Would result in a total memory use (System.totalMemory: including all the other junk)

System.totalMemory = 7 311 360

Start Over. now start with

var a:Vector.<int> = new Vector.<int>(1024 * 1024+1);

System.totalMemory = 7 315 456

Wow.. That’s a 4K jump for one int!

ok… lets add one more.

var a:Vector.<int> = new Vector.<int>(1024 * 1024+2);

System.totalMemory = 7 315 456

Exact same thing.. hmm

is it really caching a minimum of 4K for each allocation? A thousand elements caching? Nice 😉

Ok. Well that’s good to know.

So now let’s fill this array

var a:Vector.<int> = new Vector.<int>(1024 * 1024);
for (var i:int = 0; i <= 1024 * 1024; i++) { a[i] = 0 }

System.totalMemory = 8 364 032

WHAT!! That’s a 1 052 652 bytes (1 Mo) hole! ouchh

Ok… Start Over..

Let’s try to see what’s really happening in Tamarin:

Read more…

Tamarin part I : AS3 Array

Here is a little experiment:

private function InitializeArray() : void
var i:int = 0, myArray:Array = new Array();
for (i = 0; i < 100000; i++) { myArray[i] = i; }
private function InitializeArrayBackward() : void
var i:int = 0, myArray:Array = new Array();
for (i = 100000; i >=0; i--) { myArray[i] = i; }

When testing those two functions in GSkinner PerformanceTest, I get this:
InitializeArray : 11 ms
InitializeArrayBackward : 44 ms

There is something very important to understand when using the Array class.
If you read the Tamarin source code you will discover that Array is made of multiple things:

  • ArrayObject is using two data structure at the same time
  • 1: A dense array (like Vector class)
  • 2: A HashTable (like Object class)

To simplify this text, lets use “DA” for “dense array” and “HT” for “HashTable”

Read more…

Playing with GSkinner ProximityTest

I saw the use case made by GSkinner and it was funny to see the emergent pattern in there. so i modified a bit his test
to render it as Bitmap, and skip some frames so that we can see the final pattern really quickly.

Exemple at Wonderfl

A bit more about me

Before talking about more technical stuff, i’m just going to complete a little bit my portfolio in here.

Read more…

The beginning

Hi! I’m Jean-Philippe Auclair

I finally  decided to create my own blog!

Read more…

%d bloggers like this: