3

I am working with React Native and trying to create a debug build, or trying to load the build in emulator using "react-native run-anroid" command. I am getting the following error:

Error occurred during initialization of VM Could not reserve enough space for 2097152KB object heap Java HotSpot(TM) Client VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0

See the screenshot below:

enter image description here

How can I resolve this error?

skomisa
  • 16,436
  • 7
  • 61
  • 102
Vishal Pachpande
  • 500
  • 5
  • 19

3 Answers3

5

Comment below line in gradle.properties inside android folder using #

org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

To

  #  org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
Moumit
  • 8,314
  • 9
  • 55
  • 59
0

Hi If any one facing same issue while working on react native please follow bellow steps.

Variables->New: Variable name: _JAVA_OPTIONS
Variable value: -Xmx512M

Variable name: Path
Variable value: ;C:\Program Files\Java\jre6\bin;F:\JDK\bin;

you can also check link

Vishal Pachpande
  • 500
  • 5
  • 19
0

The error indicates that your memory settings for the respective gradle project aren't sufficient.

You can find your current gradle settings in the following file: /android/ > gradle.properties

org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m

will be the value setted up for a regular react-native application.

the error indicated that the given JVM args value isn't sufficient for building the app, for fixing it you can either choose to comment the given line i.e change it to:

# org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m

or you can change the JVM args value to default 512m as following:

org.gradle.jvmargs=-Xmx512m -XX:MaxMetaspaceSize=512m

The IOS part of the app runs the same before or after this change so there's no need to change anything in the ios part of the app.