Skip to content

Commit 207a363

Browse files
chrisruegerbeikov
authored andcommitted
HHH-19089 lower collection pre-sizing
see hibernate#9683 (comment) this can avoid memory peaks and CPU spikes because of heavy GC when setMaxResults is called with a very large limit e.g. Integer.MAX_VALUE (probably accidentally). it turned out the the previous limit of 1million was too large and could cause issues in production systems where legacy code bases where not aware of such collection pre-sizing
1 parent 14b3894 commit 207a363

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

hibernate-core/src/main/java/org/hibernate/sql/results/spi/ListResultsConsumer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
public class ListResultsConsumer<R> implements ResultsConsumer<List<R>, R> {
3434

3535
/**
36-
* Let's be reasonable: a row estimate greater than 1M rows is probably either a misestimate or a bug,
37-
* so let's set {@code 2^20} which is a bit above 1M as maximum collection size.
36+
* Let's be reasonable: a row estimate greater than 8k rows is probably either a misestimate or a bug,
37+
* so let's set {@code 2^13} which is a bit above 8k as maximum collection size.
3838
*/
39-
private static final int INITIAL_COLLECTION_SIZE_LIMIT = 1 << 20;
39+
private static final int INITIAL_COLLECTION_SIZE_LIMIT = 1 << 13;
4040

4141
private static final ListResultsConsumer<?> NEVER_DE_DUP_CONSUMER = new ListResultsConsumer<>( UniqueSemantic.NEVER );
4242
private static final ListResultsConsumer<?> ALLOW_DE_DUP_CONSUMER = new ListResultsConsumer<>( UniqueSemantic.ALLOW );

0 commit comments

Comments
 (0)