compose-multiplatform icon indicating copy to clipboard operation
compose-multiplatform copied to clipboard

java.lang.OutOfMemoryError: Java heap space

Open maqsats opened this issue 1 year ago • 4 comments

I am getting error: java.lang.OutOfMemoryError: Java heap space when I tried to make the release build of the iOS project.

Task :composeApp:linkReleaseFrameworkIosX64 FAILED warning: Cannot infer a bundle ID from packages of source files and exported dependencies, use the bundle name instead: ComposeApp. Please specify the bundle ID explicitly using the -Xbinary=bundleId= compiler flag. error: Compilation failed: Java heap space

  • Source files:
  • Compiler version: 1.9.22
  • Output kind: FRAMEWORK

error: java.lang.OutOfMemoryError: Java heap space at org.jetbrains.kotlin.backend.konan.util.LongArrayList.<init>(PrimitiveLists.kt:62) at org.jetbrains.kotlin.backend.konan.optimizations.DevirtualizationAnalysis$DevirtualizationAnalysisImpl$ConstraintGraphBuilder.addEdge(DevirtualizationAnalysis.kt:889) at org.jetbrains.kotlin.backend.konan.optimizations.DevirtualizationAnalysis$DevirtualizationAnalysisImpl$ConstraintGraphBuilder.doCall(DevirtualizationAnalysis.kt:1107) at org.jetbrains.kotlin.backend.konan.optimizations.DevirtualizationAnalysis$DevirtualizationAnalysisImpl$ConstraintGraphBuilder.doCall(DevirtualizationAnalysis.kt:1135) at org.jetbrains.kotlin.backend.konan.optimizations.DevirtualizationAnalysis$DevirtualizationAnalysisImpl$ConstraintGraphBuilder.dfgNodeToConstraintNode$doCall(DevirtualizationAnalysis.kt:1160) at org.jetbrains.kotlin.backend.konan.optimizations.DevirtualizationAnalysis$DevirtualizationAnalysisImpl$ConstraintGraphBuilder.dfgNodeToConstraintNode(DevirtualizationAnalysis.kt:1241) at org.jetbrains.kotlin.backend.konan.optimizations.DevirtualizationAnalysis$DevirtualizationAnalysisImpl$ConstraintGraphBuilder.build(DevirtualizationAnalysis.kt:970) at org.jetbrains.kotlin.backend.konan.optimizations.DevirtualizationAnalysis$DevirtualizationAnalysisImpl.buildConstraintGraphPrecursor(DevirtualizationAnalysis.kt:794) at org.jetbrains.kotlin.backend.konan.optimizations.DevirtualizationAnalysis$DevirtualizationAnalysisImpl.buildConstraintGraph(DevirtualizationAnalysis.kt:760) at org.jetbrains.kotlin.backend.konan.optimizations.DevirtualizationAnalysis$DevirtualizationAnalysisImpl.analyze(DevirtualizationAnalysis.kt:448) at org.jetbrains.kotlin.backend.konan.optimizations.DevirtualizationAnalysis.run(DevirtualizationAnalysis.kt:1359) at org.jetbrains.kotlin.backend.konan.driver.phases.LTOKt$DevirtualizationAnalysisPhase$2.invoke(LTO.kt:70) at org.jetbrains.kotlin.backend.konan.driver.phases.LTOKt$DevirtualizationAnalysisPhase$2.invoke(LTO.kt:56) at org.jetbrains.kotlin.backend.konan.driver.phases.PhaseBuildersKt$createSimpleNamedCompilerPhase$1.phaseBody(PhaseBuilders.kt:32) at org.jetbrains.kotlin.backend.common.phaser.SimpleNamedCompilerPhase.phaseBody(CompilerPhase.kt:207) at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedCompilerPhase.invoke(CompilerPhase.kt:94) at org.jetbrains.kotlin.backend.konan.driver.PhaseEngine.runPhase(Machinery.kt:139) at org.jetbrains.kotlin.backend.konan.driver.phases.TopLevelPhasesKt.runCodegen(TopLevelPhases.kt:360) at org.jetbrains.kotlin.backend.konan.driver.phases.TopLevelPhasesKt.runBackendCodegen(TopLevelPhases.kt:321) at org.jetbrains.kotlin.backend.konan.driver.phases.TopLevelPhasesKt.compileModule(TopLevelPhases.kt:251) at org.jetbrains.kotlin.backend.konan.driver.phases.TopLevelPhasesKt.runBackend$lambda$9$runAfterLowerings(TopLevelPhases.kt:105) at org.jetbrains.kotlin.backend.konan.driver.phases.TopLevelPhasesKt.runBackend(TopLevelPhases.kt:124) at org.jetbrains.kotlin.backend.konan.driver.DynamicCompilerDriver.produceObjCFramework(DynamicCompilerDriver.kt:76) at org.jetbrains.kotlin.backend.konan.driver.DynamicCompilerDriver.access$produceObjCFramework(DynamicCompilerDriver.kt:31) at org.jetbrains.kotlin.backend.konan.driver.DynamicCompilerDriver$run$1$1$1.invoke(DynamicCompilerDriver.kt:42) at org.jetbrains.kotlin.backend.konan.driver.DynamicCompilerDriver$run$1$1$1.invoke(DynamicCompilerDriver.kt:36) at org.jetbrains.kotlin.backend.konan.driver.PhaseEngine$Companion$startTopLevel$topLevelPhase$1.phaseBody(Machinery.kt:98) at org.jetbrains.kotlin.backend.konan.driver.PhaseEngine$Companion$startTopLevel$topLevelPhase$1.phaseBody(Machinery.kt:92) at org.jetbrains.kotlin.backend.common.phaser.SimpleNamedCompilerPhase.phaseBody(CompilerPhase.kt:207) at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedCompilerPhase.invoke(CompilerPhase.kt:94) at org.jetbrains.kotlin.backend.konan.driver.PhaseEngine$Companion.startTopLevel(Machinery.kt:105) at org.jetbrains.kotlin.backend.konan.driver.DynamicCompilerDriver.run(DynamicCompilerDriver.kt:36)

Affected platforms Select one of the platforms below:

  • iOS [release ]

Versions

  • Kotlin version: 1.9.22
  • Compose Multiplatform version: 1.6.0-rc02

To Reproduce

  1. Update to the last version of compose and try to make the release version of iOS
  2. https://terrakok.github.io/Compose-Multiplatform-Wizard/ Use default setup and make release version

Additional context I am getting this error in Xcode and Android Studio also IDE max heap size: 5120 MB Gradle daemon max heap size 2048 MB Kotlin daemon max heap size 2048 MB #Gradle org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx2048M" org.gradle.caching=true org.gradle.configuration-cache=true

maqsats avatar Feb 18 '24 23:02 maqsats

Give Xmx 8g and see what happens

pablichjenkov avatar Feb 19 '24 04:02 pablichjenkov

org.gradle.jvmargs=-Xmx8192M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx8192M" I was able to build a release with this configuration. But I started to face this problem when I upgraded Compose version to 1.6.0-rc02

maqsats avatar Feb 19 '24 11:02 maqsats

I reopened this issue, because it is possible problem for other projects as well. So, the one of possible solution is to add additional memory to build iOS application. Maybe we need to increase initial memory in template project here https://kmp.jetbrains.com/

dima-avdeev-jb avatar Feb 19 '24 11:02 dima-avdeev-jb

Seems to be a bug in the generated xcproject, as I have the JVM heap set much larger than it suggests, but it seesm to ignore it.

The Daemon will expire after the build after running out of JVM heap space.

The project memory settings are likely not configured or are configured to an insufficient value.

The daemon will restart for the next build, which may increase subsequent build times.

These settings can be adjusted by setting 'org.gradle.jvmargs' in 'gradle.properties'.

The currently configured max heap space is '3.3 GiB' and the configured max metaspace is '512 MiB'.

For more information on how to set these values, please refer to https://docs.gradle.org/8.7/userguide/build_environment.html#sec:configuring_jvm_memory in the Gradle documentation.

To disable this warning, set 'org.gradle.daemon.performance.disable-logging=true'.

Daemon will be stopped at the end of the build after running out of JVM heap space

chrisjenx avatar May 23 '24 03:05 chrisjenx

org.gradle.jvmargs=-Xmx8192M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx8192M" I was able to build a release with this configuration. But I started to face this problem when I upgraded Compose version to 1.6.0-rc02

Please where do I add this configuration? I am currently facing the same issue

Ric-AB avatar Aug 08 '24 21:08 Ric-AB

@Ric-AB grade.properties file

maqsats avatar Aug 12 '24 19:08 maqsats