Posts Tagged GC

Using Structs to Avoid Creating Garbage

It’s easy to forget about struct in C#. After all, it’s not available in other languages like Java or AS3 and it seems to have fewer features than good old class. But struct can really help you out when it comes to garbage creation! Today’s article discusses some strategies to get the most out of struct. Read on to learn how to use structs to put a stop to that pesky garbage collector!

Read the rest of this entry »

Tags: , , , ,

No Comments

Do Foreach Loops Create Garbage?

We know that we should reduce the garbage our code produces to lighten the load on Unity’s garbage collector. The trouble is that many of the ways we’re creating garbage are hidden from us. One such way to inadvertently create a lot of garbage is to use a foreach loop… at least that’s what we’ve been told. Do foreach loops really create garbage for all types of arrays, lists, dictionaries, and the rest of the collections? Do they create garbage for every loop or just the first one? Today’s article investigates to put these questions to rest. Are you safe using foreach loops or should you re-write everything to use for. Read on to find out!

Read the rest of this entry »

Tags: , , , , , ,


Keeping Bitmaps Decompressed

It came to my attention in the comments of Preloading Bitmap Decompression that Flash Player would actually free the decompressed bitmap memory if you didn’t make active use of it, similar to garbage collection. So if you followed my strategy from that article to preload a bitmap, it may have been un-preloaded for you by Flash Player! Today’s article shows you how to work around this little problem.

Read the rest of this entry »

Tags: , , , , ,


Top 10 Performance Tips for 2012

It’s a new year and it’s time to make some New Years resolutions for Flash performance. Today’s article is a collection of what i consider 10 top tips for improving the performance of your Flash apps. Read on for the list!

Read the rest of this entry »

Tags: , , ,


Even Faster Linked Lists

Linked lists can be much faster than AS3’s Array and Vector classes if you use them under the right circumstances. It’s been over a year and a half since I last visited the topic, but today it’s time to update my LinkedList class. Read on for the freshly-optimized code and all-new performance testing and analysis!

Read the rest of this entry »

Tags: , , , , ,


Hidden Object Allocations

During some recent memory profiling I was reacquainted with just how many ways there are to unknowingly allocate an object in AS3. The problem is seldom the allocation itself, but rather the later garbage collection (GC) to delete those objects. Ever used a Flash profiler only to see a huge chunk of your CPU time going to [reap], [mark], or [sweep]? Yeah, that’s the GC at work. Today’s article talks about some of the ways you end up allocating objects in AS3 without using the new keyword. These subtle errors can end up costing you!

Read the rest of this entry »

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


Improving Vector3D

The Vector3D class debuted in Flash Player 10.0 as Adobe’s official implementation of, well, a 3D mathematical vector (not the pseudo-Array class Vector). Weirdly, it has a w component and is therefore technically a 4D vector, but its API inconsistently make use of the fourth dimension. There are also strange oversights, inefficiencies, and functionality it really should have always had. Read on for my custom Vector3D derivative—Vector3DExt—that fixes all of these problems by extending and improving on the original.

Read the rest of this entry »

Tags: , , , , , , , , ,


The Importance of Pre-Allocation

When you construct an Array or a Vector, you can specify an initial size. Why would you do this?There are various reasons you may want to reserve initially-unused slots for logic reasons, but are there any performance gains to be had by pre-allocating this space for an Array or Vector you intend to completely fill right away? Today I’ll take a look to see just how much performance can be gained by pre-allocating Arrays and Vectors.

Read the rest of this entry »

Tags: , , , , , ,