Closed JakeWharton closed 10 years ago
Poor man's pool?
private static abstract class Pool<T> {
private final Deque<T> pool;
Pool(int initialSize) {
pool = new ArrayDeque<T>(initialSize);
for (int i = 0; i < initialSize; i++) {
pool.addLast(newObject());
}
}
T obtain() {
return pool.isEmpty() ? newObject() : pool.removeLast();
}
void restore(T instance) {
pool.addLast(instance);
}
protected T newObject();
}
3b770ea89ec28d37d15861b1e5f14294f44fc3aa
It's currently allocating a TON inside of a
draw
call.