Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String multiplication + mkString causes OutOfMemoryError in Scala 2.13.0-M4 #11031

Closed
xerial opened this issue Jul 19, 2018 · 2 comments
Closed

Comments

@xerial
Copy link

xerial commented Jul 19, 2018

This simple code causes OutOfMemoryError in Scala 2.13.0-M4:

("?" * 10).mkString(",")
[error] (run-main-0) java.lang.OutOfMemoryError: Java heap space
[error] java.lang.OutOfMemoryError: Java heap space
[error] 	at java.util.Arrays.copyOf(Arrays.java:3332)
[error] 	at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124)
[error] 	at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:649)
[error] 	at java.lang.StringBuilder.append(StringBuilder.java:202)
[error] 	at scala.collection.mutable.StringBuilder.append(Builder.scala:209)
[error] 	at scala.collection.StringOps$.addString$extension2(StringOps.scala:524)
[error] 	at scala.collection.StringOps$.mkString$extension0(StringOps.scala:496)
[error] 	at scala.collection.StringOps$.mkString$extension1(StringOps.scala:504)
[error] 	at Sample2$.main(Sample2.scala:3)
[error] 	at Sample2.main(Sample2.scala)
[error] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] 	at java.lang.reflect.Method.invoke(Method.java:498)
[error] 	at sbt.Run.invokeMain(Run.scala:93)
[error] 	at sbt.Run.run0(Run.scala:87)
[error] 	at sbt.Run.execute$1(Run.scala:65)
[error] 	at sbt.Run.$anonfun$run$4(Run.scala:77)
[error] 	at sbt.Run$$Lambda$4891/1073245253.apply$mcV$sp(Unknown Source)
[error] 	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error] 	at sbt.util.InterfaceUtil$$anon$1.get(InterfaceUtil.scala:10)
[error] 	at sbt.TrapExit$App.run(TrapExit.scala:252)
[error] 	at java.lang.Thread.run(Thread.java:748)
[error] java.lang.RuntimeException: Nonzero exit code: 1
[error] 	at sbt.Run$.executeTrapExit(Run.scala:124)
[error] 	at sbt.Run.run(Run.scala:77)
[error] 	at sbt.Defaults$.$anonfun$bgRunTask$5(Defaults.scala:1168)
[error] 	at sbt.Defaults$.$anonfun$bgRunTask$5$adapted(Defaults.scala:1163)
[error] 	at sbt.internal.BackgroundThreadPool.$anonfun$run$1(DefaultBackgroundJobService.scala:366)
[error] 	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error] 	at scala.util.Try$.apply(Try.scala:209)
[error] 	at sbt.internal.BackgroundThreadPool$BackgroundRunnable.run(DefaultBackgroundJobService.scala:289)
[error] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[error] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[error] 	at java.lang.Thread.run(Thread.java:748)

A workaround is adding toSeq:

("?" * 10).toSeq.mkString(",")
@xerial
Copy link
Author

xerial commented Jul 19, 2018

Duplicate of #10951?

@SethTisue
Copy link
Member

Duplicate of #10951

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants