Fix unbounded memory usage.