Posts Tagged string

When getSize() Lies

flash.sampler.getSize() is a handy tool for figuring out how much memory a class instance uses. However, it is often flat-out wrong. Today’s article tries it out on a variety of classes to find out which ones it works on and which ones it doesn’t.

Read the rest of this entry »

Tags: , , , , , , , , , , , ,

4 Comments

How Big Is That Class?

When you instantiate one of your classes, how much memory does it use? Today’s article tries out a lot of combinations and counts the bytes used. The conclusion is easy to remember and will give you a solid understanding of how much memory your app is using.

Read the rest of this entry »

Tags: , , , , , , , ,

5 Comments

Four Ways to Clean Master Strings

When I first wrote about master strings I proposed a function that would help to trim them down and potentially save a lot of memory. However, that method still resulted in a string with a master string one longer than it. Ideally, we’d have no master string at all. Since then, three astute readers chimed in with alternate solutions to the problem. Today I put try all three out to see which method does the best job of cleaning master strings.

Read the rest of this entry »

Tags: , , , ,

6 Comments

String Keys vs. Int Keys

Now that we know you can use int keys with Object, it’s time to test whether or not this is any faster than String keys. Today’s article does just that and also tests int and String keys with Dictionary.

Read the rest of this entry »

Tags: , , , , , ,

5 Comments

Using Non-String Keys with Object

Pop quiz: what’s the difference between an Object and a Dictionary? If you said “Dictionary can have non-String keys”, you bought into a common myth. Today’s article shows the cases where the lowly Object class will use non-String keys whether you like it or not. Read on for the details.

Read the rest of this entry »

Tags: , , , ,

6 Comments

5x Faster For-In Loops

I’ve recently been notified of a way to dramatically speed up for-in loops. I’ve tested this method out and indeed there is a 5x speedup. Employing the technique is also really easy. Unfortunately, the speedup is sometimes an illusion. Read on to learn a little more about for-in loops and how you could potentially speed yours up by 5x.

Read the rest of this entry »

Tags: , , ,

9 Comments

The Four Vector Classes

There are four Vector classes in AS3. It seems like there is only one—Vector—and that it supports generics, but that is only an illusion. Today’s article will do some tests to reveal the implications to your app’s correctness and efficiency.

Read the rest of this entry »

Tags: , , , , , , , ,

3 Comments

Multi-Line Strings

AS3 has never had very good support for multi-line strings… until now. Today’s article discusses the proper and improper ways of writing multi-line strings and delves into the bytecode so you really understand what’s going on.

Read the rest of this entry »

Tags: , ,

14 Comments

How To Fix the XML Memory “Leak”

Dealing with XML files can very easily trigger Flash to “leak” memory. Your app may only keep a tiny fraction of the XML file’s contents, but the whole file may stay in memory and never get garbage collected. Today’s article examines how this happens and how you can clean up all that unused memory.

Read the rest of this entry »

Tags: , , , , , ,

20 Comments

String.charCodeAt Is Really Fast

String.charCodeAt is a simple function so you might expect the function call overhead (huge in AS3) to making calling it frequently quite slow. You’d think that there’s no way an charCodeAt-using AS3 function could beat a built-in String function like indexOf. Would you be right? Today’s article examines this special function to see if we might defy conventional wisdom and achieve a performance boost.

Read the rest of this entry »

Tags: , , ,

4 Comments