0

I've had a lot of applications left alone and given up because they got a lot of libraries and classes so eventually I got this memory error. Recently I started using JProfiler. But still didn't help not to cause it the app got a little big and now again this happend. Check out my setting:

in gradle.properties

org.gradle.jvmargs=-Xmx16g -XX:MaxPermSize=16g -XX:+HeapDumpOnOutOfMemoryError
GRADLE_OPTS=-Xmx16g

in gradle(app)

dexOptions { javaMaxHeapSize "16g" }

it sounds like these values don't make no difference give them 1G or 100G.T his is not important then what is?T here's a committed size in JProfiler it's only 230 MB. Before even running the App 80MB is used already! Check out the pictures:

Idle: enter image description here

The memory Error: enter image description here

This committed size is where the Out-Of-Memory error happens. As you see in the pictures. This happens when I press the run button and it doesn't run it gives the memory error but in the mean time in JProfiler the used size gets close to committed size and when it's close enough boom the error comes. How to increase this committed size then?It's not my device left memory that is around 1.55 GB now. Then what is it? I'm not supposed to create a hello world application. I wrote totally clean code and I'm not causing this the app worked perfectly nothing's slow nothing gets overflowed. But when I add more libraries not even using them yet! I get memory error. Here's the heap walker:

enter image description here

looks pretty normal to me.char and String are at the top what do I do?Please help me. Thank you!

rds
  • 26,253
  • 19
  • 107
  • 134
Steve Moretz
  • 2,758
  • 1
  • 17
  • 31

1 Answers1

0

I don't know about gradle specifics, but the standard switch for setting the MaxHeapSize is -Xmx; looking here may help: Run application via gradlew with -Xmx and -Xms.

If you are talking about running the app (as opposed to "building it") you could try to build the final JAR first and run it as a standalone application (via java -Xmx... -jar).

Do you get any specific OOM error?

Btw. based on the -XX:MaxPermSize you posted it seems you're using a really old pre-Java 8 version (or you don't set JVM args properly). You should consider an upgrade.

Juraj Martinka
  • 3,991
  • 2
  • 23
  • 25
  • Thanks for the answer I don't want to use gradlew.It – Steve Moretz May 28 '19 at 14:53
  • 's so annoying and slower.The problem is that Xmx doesn't make any effect at all I put it to 1g or 16g it's all the same.I found a file in D:\.gradle\gradle.properties and changed the stuff in it to : org.gradle.jvmargs=-Xmx5g -XX:MaxPermSize=5g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 org.gradle.daemon=true Now it works the point is the gradle.properties in my projects are overriden by this value and they don't work.Does anybody have the same issue – Steve Moretz May 28 '19 at 14:58