Memory problem with daemon

We were having trouble getting SAB to work on a Windows 7 32-bit computer with 4GB of RAM. We were getting the error:

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

With a bit of internet research it looked like the solution was to define the amount of memory that gradle was allowed to use, but most of the references were to using Android studio, and it wasn’t clear where to set the memory properties. With a little trial and error I found that creating this file:

C:\Users\<user>\.gradle\gradle.properties

and putting this line in the file:

org.gradle.jvmargs=-Xmx512m

then attempting to build the app again, seems (at least on first try) to have solved the problem.

I post this in case in helps someone, or in case I need it again in the future… :slight_smile:

1 Like

Jeff,

I have to wonder how you have a 32bit machine that is still running. Or is it a 64bit with a 32bit OS installed.

I put some similar advice here: https://github.com/SILAsiaPub/AppBuilder-workaround
Though one user doubled the value twice before it worked for him. Though increasing the value can cause other issues I believe.

Ian

It is a real 32-bit Windows 7 computer. I don’t really know its history, but it is still being used…

Sure enough, you do have a solution in that link. And now I see another thread in this forum:

I did actually search for this problem, both on Google and in this forum, but must have chosen my search terms very poorly. Now, just about every combination I try to search for comes up with a solution. Must have just been one of those days… :slight_smile:

Thank you, it works well on Windows 10! As per advice I put my gradle.properties file at C:\Users\me\.gradle with this contents:

org.gradle.jvmargs=-XX:MaxHeapSize=256m -Xmx256m

Alternatively on Windows, it also works if I add an environment variable _JAVA_OPTIONS with the value -Xmx256M instead of using the gradle.properties file.

However, both these options are system-wide. I have a few other tools that uses gradle as build system and need to use different settings at different times.

I tried many alternative locations to put the gradle.properties file in for SAB (and removed the global one and the environment variable during testing), before finding that only D:\Programs\Scripture App Builder\.gradle\gradle.properties works. [path on my system]

Note: It also turns out that if you place ‘different versions’ of this file in both global and local folders, it seems the global one overrides. Makes sense. If you put it just in local (none in global), it seems to work fine.

PS: As I was writing to explain what I tried, I tried some more and found above result so my question became a suggestion. I guess it sometimes helps to try and describe your problem logically to make sure you didn’t miss any steps :wink:

Hope it helps someone.

Regards