Mehar Shahani
Mehar Shahani

Reputation: 89

Android Studio Error : build fails every time I try to run the application on my phone

"Error occurred during initialization of VM Could not reserve enough space for 1048576KB object heap"

I am trying to run the Android application on my OnePlus2 phone but I get this error message each time. Also the in-built emulator doesn't work either.

How do i solve this?

Upvotes: 3

Views: 43

Answers (1)

Gabe Sechan
Gabe Sechan

Reputation: 93678

Don't try to allocatie a 1 GB object (which is what you're trying to do). That will fail on pretty much every phone- not only do most older phones not have that much memory available (remember you're sharing with the OS and other apps), but the amount that is available to the Java heap- the amount you can allocate with new- is generally limited to a much smaller amount. As low as 100 MB on many devices.

Figure out why you're trying to allocate so much memory, and find a way to not do that.

Upvotes: 1

Related Questions