1

I'm developing my first game for android. I am using milkman ane in my project. It was working fine, until the new version (2.1.0).

So now I am getting an OutOfMemoryError on the packaging apk. This might be relevant, I use flashdevelop IDE. I had found some solutions to increase java heap space (by putting params -Xms1024M -Xmx1024M). But they didn't help in my situation.

Here is what I have tried:

1) Set the parameters to sdk/bin/jvm.config: no result

2) Put the java parameters into adt.bat in flex sdk. But it looks like @java -jar "%~dp0\..\lib\adt.jar" %*. So this doesn't help.

3) I've found that parameters should be set into "program files(x86)/ADT/bin/adt.bat". But there is nothing like that on my computer. I mean there are many adt.bat files in different apps, but they all look like in second solution. I couldn't find the main(?) adt.bat.

4) I've tried to put parameters into project/bat/packager.bat (where adt is called) but it causes the package to crash. I've tried to put parameters in different places of adt call, but every time - same result.

5) I've even added _JAVA_OPTIONS environment variable. Becauses message "picked up _JAVA_OPTIONS -xmx1024M" But...Then still the same error.

I really need somebody to help me. Where could my mistake be?

buczek
  • 2,011
  • 7
  • 29
  • 40
Paul Swarrow
  • 31
  • 1
  • 4
  • Let me see if I get it right: you received the exception while the app was running or when the IDE created the apk to install it on the device? – Iulian Popescu Jul 14 '16 at 16:59
  • You usually run out of memory because there's a bug in the code. Could you post the stack trace of the error and the code where the error gets thrown? – Mick Mnemonic Jul 14 '16 at 17:02
  • You should read **[this Answer](http://stackoverflow.com/a/10822672/2057709)**. It might be useful to you. Anyways your problem started when you used a newer version of some ANE made by the company MilkMan so maybe its up to them to fix the code issue in their ANE (do they know? contact them) or else you move back to a last working version of the ANE... – VC.One Jul 15 '16 at 03:29

2 Answers2

1

Try adding this to the manifest under the application element:

android:largeHeap="true"

You can read more about it here.

Harsh Pandey
  • 831
  • 7
  • 12
  • Nope, same error. (As I understood, It should be like: ....) – Paul Swarrow Jul 14 '16 at 22:56
  • If that didn't work, then I am inclined to believe that there is some bug in your code. Also, you might want to try calling `this.finish()` in your activities once you don't need them anymore. – Harsh Pandey Jul 15 '16 at 00:43
1

Here is similar question. https://forums.adobe.com/thread/1047755

Addidng the following line to your .bash_profile:

export _JAVA_OPTIONS="-Xms1024m -Xmx4096m -XX:MaxPermSize=512m"

Reload:

$ source ~/.bash_profile

And build apk.

I know that you had tried _JAVA_OPTIONS, but -xmx1024M may be small.

nshmura
  • 5,940
  • 3
  • 27
  • 46