Post tutorial RSS Hooking the ASOD Garbage Collector

If you don't want lag in your mod, you really want to read this. You need the source code from the official website.

Posted by on - Intermediate Client Side Coding

Why Bother?
The ASOD game engine can handle as high quality graphics as you want. That is why there is no compression on the ASOD data files. However, due to this, the Java memory allocation fills up fairly quickly. In fact it fills up with just the data from Ziaac and Pionis!

Knowing that, you see why a garbage collector is important. The Java collector does a pretty terrible job of clearing graphics that aren't actually being drawn on the screen. So, I implemented one in .

How does it work?
The current solar system of the player is stored as a string in the player obect. It works by setting all graphics to null first via GarbageCollector's clearCache() function.

if (player.currentSolarSystem.matches(space[i].solar) == false) {
                //If it is not in the current system clear it
                space[i].dockedTexture = null;
                space[i].planetTexture = null;

That way no texture is used. But this introduces a problem. Now there are no textures, so it loads them back into the memory if and only if they are in the same solar system as the player.

Hooking the Collector

if (i == 0) {

That is a sample, it works on object 0 (Remember that i is linking to objects in the universe, in this case 0 is sigos in ziaac).

As you can see it reloads the required textures. To create your own collector you simply follow this template while changing the array index (space[#] where # is the object's position in the array) and the graphics to be loaded.

Simply add your code to the long list (39 at the time of writing) near identical copies of this code in

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.