Skip to content
Rafael Pax edited this page Jun 22, 2017 · 21 revisions

Automatically rewrite components so that instances are recycled. This feature helps mitigate garbage collection related freezes and stuttering on the Android platform. It is considered stable.

Prerequisites

Processing of @PooledWeaver annotated components is done at build-time. See bytecode weaving and weave automation for how to configure it.

Minimal example

What you type:

@PooledWeaver
public class ExampleComponent extends Component {
    public float x;
    public float y = 2;
    public String stringA;
    public String stringB = "hi";
    public SomeOtherType obj
}

What the JVM gets:

public class ExampleComponent extends PooledComponent {
    public float x;
    public float y = 2;
    public String stringA;
    public String stringB = "hi";
    public SomeOtherType obj;
    
    @Override
    protected void reset() {
        x = 0;
        y = 2;
        stringA = null;
        stringB = "hi";
        // non-primitive types are left intact (obj)
    }
}

Resettable types

  • all primitive values
  • java.lang.String

Cleared types

  • com.artemis.utils.Bag, com.artemis.utils.IntBag
  • all java.util.List, java.util.Set, java.util.Map
  • all com.badlogic.gdx.utils.*Array, com.badlogic.gdx.utils.*Map
Clone this wiki locally