Vishal Pachpande
Vishal Pachpande

Reputation: 540

React Native eror "Could not reserve enough space for 2097152KB object heap"

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?

Upvotes: 4

Views: 5372

Answers (4)

Aryan Sharma
Aryan Sharma

Reputation: 11

If anyone still facing this issue while running VM(virtual machine) for react native. Follow below steps:

  1. Go to project directory
  2. then go to android --> gradle.properties. comment down org.gradle.jvmargs line

Upvotes: 1

Pavan Aditya M S
Pavan Aditya M S

Reputation: 375

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.

Upvotes: 0

Moumit
Moumit

Reputation: 9630

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

Upvotes: 12

Vishal Pachpande
Vishal Pachpande

Reputation: 540

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

Upvotes: 0

Related Questions