Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Pavel Markevič
Pavel Markevič
10,402 Points

Gradle 'FunFacts' project refresh failed

Error:Unable to start the daemon process. This problem might be caused by incorrect configuration of the daemon. For example, an unrecognized jvm option is used. Please refer to the user guide chapter on the daemon at http://gradle.org/docs/1.12/userguide/gradle_daemon.html

Please read below process output to find out more:

Error occurred during initialization of VM Could not reserve enough space for object heap Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.

Screenshot: http://gyazo.com/8513445816c789a09133cb4b14541d99

Harry James
Harry James
14,780 Points

Hey Pavel!

Judging by the error message, it looks like Java did not have enough RAM to start up!

Not to worry though, this can be fixed but, in order to give you the best experience with Android Studio, can you please tell me what your RAM is and whether you are running a 32-bit or 64-bit system?

Thanks in advance! :)

1 Answer

Harry James
Harry James
14,780 Points

Ok. I came up with some settings that should best suit your system. In case you were wondering, the settings I'm giving you will allocate a maximum of 3gb of RAM to the Virtual Machine and the Virtual Machine will initiate itself with 524mb (1/2gb of RAM but this will automatically increase up to a maximum of 3gb).

To set these settings, in Android Studio, go to File >> Settings >> Project Settings >> Compiler >> VM Options and enter this value:

-Xmx3072m -XX:MaxPermSize=524m

Then, press OK.

Let me know how this goes for you! :)

Pavel Markevič
Pavel Markevič
10,402 Points

Not really helped :( is there any other ways?

Harry James
Harry James
14,780 Points

This is the only way to solve this problem.

Could you please check gradle.properties in your project folder and see if the memory tweak is in that file also?

If it is and you are still having the problem, could you provide a screenshot of how much memory is used by your PC when you have Android Studio open.

Pavel Markevič
Pavel Markevič
10,402 Points

where can I find or type gradle.properties ?

Harry James
Harry James
14,780 Points

It is found in the

C:\Users\YourName\AndroidStudioProjects\ProjectName

directory by default (Replace YourName and ProjectName with the corresponding values).

Harry James
Harry James
14,780 Points

Your PC does have a very high usage and is close to your 4gb maximum of RAM.

The last thing I would try is to add this value into your gradle.properties

-Xmx3072m -XX:MaxPermSize=524m

then go to File >> Invalidate caches & restart >> Invalidate and Restart.

If even after that you have the same issue, I would try this again after closing down as many memory-hogging processes as possible and seeing if you can then start up the Virtual Machine. If you can after closing down multiple processes, you can either do this every time you want to start the VM or you can upgrade your PC (Note that this would probably mean getting a new computer because a 32-bit system can only take a maximum of 4gb of RAM).

If you still get the error even after closing down memory-hogging processes then please tell me what your RAM level is when you have Android Studio open but other processes ended.

It's not quite the news I wanted to give you but, sadly, Android Studio is extremely resource hogging and so are other IDE's like Eclipse.

Best of luck!

Pavel Markevič
Pavel Markevič
10,402 Points

Same when memory eating processes are closed... screen of usage: http://gyazo.com/767ac80e9077fcaa40fced006f20174f

Harry James
Harry James
14,780 Points

Android Studio should definitely run at that level - It only needs 2GB RAM minimum.

Could you try closing Android Studio and then deleting your .gradle folder? It's located at C:\Users\YourName. After that, open up Android Studio again and it will re-create the folder.

Let me know how it goes!

Pavel Markevič
Pavel Markevič
10,402 Points

Didn't work. I think I should buy new notebook ? Sokething like that would work Asus X552CL GAMER / 15.6" / Intel® Core™ i3-3217u / 4GB / 750GB / GeForce® GT™710M ?

Harry James
Harry James
14,780 Points

I don't think that would make any difference as the system would also be 4GB.

I am still puzzled as to why Android Studio is not working on your system even though it has more than 2GB RAM available. I would like to try one last thing which is to change the Global Java Property. This isn't recommended because it means all Java applications will initiate with 524mb even if they use less but, I would still like to see if this makes any difference.

To change this setting it is a little complicated. I'll try my best to make it easy to follow along.

Open up your System Properties (The bit you had open before that shows your CPU/RAM values) >> On the left sidebar, click Advanced System Settings >> Click Environment Variables >> Under System Variables, press New >> Use the values below:

// Variable name:
_JAVA_OPTIONS
// Variable value:
-Xmx524M

then, press OK and try again.

If this makes no difference, go ahead and delete the variable because it can make for inefficiencies for some Java Applications.

Let me know how it goes!

Pavel Markevič
Pavel Markevič
10,402 Points

Hey Harry, it works after I added that variable! Thanks a lot:) about new pc/notebook - I bought my oldie in 2007 I guess, so I think it had a long time and should retire... I don't think it would be the same on a new computer with 4GB RAM ? :) Thanks for Your help once more

Harry James
Harry James
14,780 Points

Woohoo! Glad you can get Android Studio with this change! It's not the most beneficial but at least you can work with it!

It may work better with a new computer but, I would recommend you get a computer with a higher amount of RAM than your current one if you are considering getting a new system (It is worth it in the long run!)