1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Scaladoc で OutOfMemory が出た時の対処

Last updated at Posted at 2013-09-30

Scalaのライブラリを使いたいけど、ドキュメント見つからない!
ってときは、自分で scaladocコマンド で生成します。

ただ、大きなライブラリからドキュメント生成しようとするとOutOfMemoryで失敗することがあります。

$ scaladoc -d doc/ -s src/main/scala/**/*.scala

実行!

uncaught exception during compilation: java.lang.OutOfMemoryError
three errors found
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at scala.reflect.internal.util.HashSet.growTable(HashSet.scala:97)
	at scala.reflect.internal.util.HashSet.findEntryOrUpdate(HashSet.scala:39)
	at scala.reflect.internal.Types$class.unique(Types.scala:3940)
 
...

ギャー!

そんなときは、JAVA_OPTS に JVM で利用するメモリ量を指定することで対処できます。

$ export JAVA_OPTS="-Xms256m -Xmx1024m"
$ scaladoc -d doc/ -s src/main/scala/**/*.scala

Xms は初期 / Xmx は最大ヒープサイズです

おまけ

scaladoc のコードを追っていくと

[[ -n "$JAVA_OPTS" ]] || JAVA_OPTS="-Xmx256M -Xms32M"

...

execCommand \
  "${JAVACMD:=java}" \
  $JAVA_OPTS \
  "${java_args[@]}" \
  $(classpathArgs) \
  -Dscala.home="$SCALA_HOME" \
  -Dscala.usejavacp=true \
  $EMACS_OPT \
  $WINDOWS_OPT \
   scala.tools.nsc.ScalaDoc  "$@"

という箇所があります。
JAVA_OPTSが指定されていなければ、デフォルトで最大ヒープサイズ 256MB 使うとなってます。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?