Memory consumption in java Collection.sort ()

I have an ArrayList filled with 1.5 million objects of some class. When I sort this list using the Collection.sort method, the allocated JVM memory increases dramatically.

So my questions are:

This is normal? What could be the reason for this? Is this a garbage collector question that runs too slow or doesn't start often enough? Do the objects in the list have to fulfill certain specifications in order to consume less memory during sorting (in addition to not contain so much data)?

thanks!

+4
source share
1 answer

List, , . , . , , , .

Java 8 , List. . ArrayList , . , Java 8 .

. , , , , , .

, , Tim Sort Java 7 Arrays::sort. Tim . javadoc:

n/2 .

, , java.util.Arrays.useLegacyMergeSort true.

, , , , , .

+4

Source: https://habr.com/ru/post/1608769/


All Articles