Skip to content

Commit

Permalink
Adds PooledEngine.clearPools()
Browse files Browse the repository at this point in the history
  • Loading branch information
dsaltares committed Sep 1, 2014
1 parent f9112ab commit 2837299
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ashley/src/com/badlogic/ashley/core/PooledEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ public <T extends Component> T createComponent(Class<T> componentType) {
return componentPools.obtain(componentType);
}

/**
* Removes all free entities and components from their pools.
* Although this will likely result in garbage collection, it will free up memory.
*/
public void clearPools() {
entityPool.clear();
componentPools.clear();
}

private class PooledEntity extends Entity implements Poolable {

@Override
Expand Down Expand Up @@ -169,5 +178,11 @@ public void freeAll(Array objects) {
free(object);
}
}

public void clear() {
for (Pool pool : pools.values()) {
pool.clear();
}
}
}
}

0 comments on commit 2837299

Please sign in to comment.