-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
10, 11
-
x86_64
-
windows_10
A DESCRIPTION OF THE PROBLEM :
Getting a java.lang.OutOfMemoryError: Java heap space when calling Stream.iterator().next() on a stream which uses an infinite/very big Stream in flatMap.
As far as I understand this is related to the bugJDK-8196106 .
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run code below
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Termination without output
ACTUAL -
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.base/java.util.stream.SpinedBuffer$OfInt.newArray(SpinedBuffer.java:750)
at java.base/java.util.stream.SpinedBuffer$OfInt.newArray(SpinedBuffer.java:723)
at java.base/java.util.stream.SpinedBuffer$OfPrimitive.ensureCapacity(SpinedBuffer.java:508)
at java.base/java.util.stream.SpinedBuffer$OfPrimitive.increaseCapacity(SpinedBuffer.java:516)
at java.base/java.util.stream.SpinedBuffer$OfPrimitive.preAccept(SpinedBuffer.java:569)
at java.base/java.util.stream.SpinedBuffer$OfInt.accept(SpinedBuffer.java:768)
at java.base/java.util.stream.StreamSpliterators$IntWrappingSpliterator$$Lambda$3/940060004.accept(Unknown Source)
at java.base/java.util.stream.ReferencePipeline$8$1$$Lambda$4/998351292.accept(Unknown Source)
at java.base/java.util.stream.Streams$RangeIntSpliterator.tryAdvance(Streams.java:82)
at java.base/java.util.stream.ReferencePipeline$8$1.accept(ReferencePipeline.java:326)
at java.base/java.util.stream.Streams$StreamBuilderImpl.tryAdvance(Streams.java:397)
at java.base/java.util.stream.StreamSpliterators$IntWrappingSpliterator.lambda$initPartialTraversalState$0(StreamSpliterators.java:347)
at java.base/java.util.stream.StreamSpliterators$IntWrappingSpliterator$$Lambda$5/335471116.getAsBoolean(Unknown Source)
at java.base/java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.fillBuffer(StreamSpliterators.java:206)
at java.base/java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.doAdvance(StreamSpliterators.java:161)
at java.base/java.util.stream.StreamSpliterators$IntWrappingSpliterator.tryAdvance(StreamSpliterators.java:358)
at java.base/java.util.Spliterators$2Adapter.hasNext(Spliterators.java:726)
at java.base/java.util.Spliterators$2Adapter.nextInt(Spliterators.java:732)
at BugReport.main(BugReport.java:18)
---------- BEGIN SOURCE ----------
import java.util.function.Function;
import java.util.stream.IntStream;
import java.util.stream.Stream;
public class BugReport
{
public static void main(String[] args)
{
Stream
.of(IntStream.range(0, Integer.MAX_VALUE))
.flatMapToInt(Function.identity())
.iterator()
.nextInt();
}
}
---------- END SOURCE ----------
FREQUENCY : always
Getting a java.lang.OutOfMemoryError: Java heap space when calling Stream.iterator().next() on a stream which uses an infinite/very big Stream in flatMap.
As far as I understand this is related to the bug
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run code below
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Termination without output
ACTUAL -
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.base/java.util.stream.SpinedBuffer$OfInt.newArray(SpinedBuffer.java:750)
at java.base/java.util.stream.SpinedBuffer$OfInt.newArray(SpinedBuffer.java:723)
at java.base/java.util.stream.SpinedBuffer$OfPrimitive.ensureCapacity(SpinedBuffer.java:508)
at java.base/java.util.stream.SpinedBuffer$OfPrimitive.increaseCapacity(SpinedBuffer.java:516)
at java.base/java.util.stream.SpinedBuffer$OfPrimitive.preAccept(SpinedBuffer.java:569)
at java.base/java.util.stream.SpinedBuffer$OfInt.accept(SpinedBuffer.java:768)
at java.base/java.util.stream.StreamSpliterators$IntWrappingSpliterator$$Lambda$3/940060004.accept(Unknown Source)
at java.base/java.util.stream.ReferencePipeline$8$1$$Lambda$4/998351292.accept(Unknown Source)
at java.base/java.util.stream.Streams$RangeIntSpliterator.tryAdvance(Streams.java:82)
at java.base/java.util.stream.ReferencePipeline$8$1.accept(ReferencePipeline.java:326)
at java.base/java.util.stream.Streams$StreamBuilderImpl.tryAdvance(Streams.java:397)
at java.base/java.util.stream.StreamSpliterators$IntWrappingSpliterator.lambda$initPartialTraversalState$0(StreamSpliterators.java:347)
at java.base/java.util.stream.StreamSpliterators$IntWrappingSpliterator$$Lambda$5/335471116.getAsBoolean(Unknown Source)
at java.base/java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.fillBuffer(StreamSpliterators.java:206)
at java.base/java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.doAdvance(StreamSpliterators.java:161)
at java.base/java.util.stream.StreamSpliterators$IntWrappingSpliterator.tryAdvance(StreamSpliterators.java:358)
at java.base/java.util.Spliterators$2Adapter.hasNext(Spliterators.java:726)
at java.base/java.util.Spliterators$2Adapter.nextInt(Spliterators.java:732)
at BugReport.main(BugReport.java:18)
---------- BEGIN SOURCE ----------
import java.util.function.Function;
import java.util.stream.IntStream;
import java.util.stream.Stream;
public class BugReport
{
public static void main(String[] args)
{
Stream
.of(IntStream.range(0, Integer.MAX_VALUE))
.flatMapToInt(Function.identity())
.iterator()
.nextInt();
}
}
---------- END SOURCE ----------
FREQUENCY : always
- relates to
-
JDK-8196106 Support nested infinite or recursive flat mapped streams
- Resolved