Enable GC of JSTypeResolver.resolutionQueue.
@@ -100,8 +100,8 @@ public final class JSTypeResolver {
*/
private final ArrayDeque<JSType> captureStack = new ArrayDeque<>();
- /** The sequence of types to resolve then the resolver is closed. */
- private final ArrayDeque<JSType> resolutionQueue = new ArrayDeque<>();
+ /** The sequence of types to resolve when the resolver is closed. */
+ private ArrayDeque<JSType> resolutionQueue = new ArrayDeque<>();
private State state = State.CLOSED;
@@ -179,8 +179,11 @@ public final class JSTypeResolver {
this.state = State.CLOSING;
- while (!this.resolutionQueue.isEmpty()) {
- this.doResolve(this.resolutionQueue.removeFirst());
+ // resolutionQueue scales with the size of the application, so it needs to be GC-able.
+ ArrayDeque<JSType> queue = this.resolutionQueue;
+ this.resolutionQueue = new ArrayDeque<>();
+ while (!queue.isEmpty()) {
+ this.doResolve(queue.removeFirst());
}
this.state = State.CLOSED;
