Created
April 13, 2020 10:52
-
-
Save marchof/4f58d941e60fe56e20594d6f3c75314f to your computer and use it in GitHub Desktop.
Object allocation with streams
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SITES BEGIN (ordered by live bytes) Mon Apr 13 12:50:49 2020 | |
percent live alloc'ed stack class | |
rank self accum bytes objs bytes objs trace name | |
1 24.86% 24.86% 23266544 415474 56000000 1000000 300456 java.util.stream.ReferencePipeline$Head | |
2 14.21% 39.07% 13295168 415474 32000000 1000000 300409 java.util.Spliterators$ArraySpliterator | |
3 10.65% 49.72% 9971376 415474 24000000 1000000 301708 java.util.stream.ReduceOps$2ReducingSink | |
4 10.65% 60.37% 9971376 415474 24000000 1000000 301706 java.util.stream.ReduceOps$2 | |
5 10.65% 71.03% 9971376 415474 24000000 1000000 300396 java.lang.Integer[] | |
6 7.10% 78.13% 6647584 415474 16000000 1000000 301697 java.util.function.BinaryOperator$$Lambda$2.1406718218 | |
7 7.10% 85.23% 6647584 415474 16000000 1000000 301711 java.util.Optional | |
8 7.10% 92.34% 6647584 415474 15997952 999872 301712 java.lang.Integer | |
9 7.10% 99.44% 6647584 415474 15997936 999871 301713 java.lang.Integer | |
10 0.01% 99.45% 12568 66 12640 67 300770 char[] | |
SITES END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.stream.Stream; | |
// run with -agentlib:hprof=heap=sites,file=streams.txt | |
public class StreamUbuse { | |
public static void main(String[] args) { | |
int max = 0; | |
for (int i = 0; i < 1_000_000; i++) { | |
max = Stream.of(i, max).max(Integer::compareTo).get(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment