4

As far as I'm aware, each Android phones limits all apps to a maximum memory usage of about 16, 24 or 32Mb. I've just seen people discussing the app Dungeon Defenders which apparently seems to make use of 256 Mb of RAM.

App description: "Minimum Requirements: 512 MB RAM (256 free at runtime)" http://www.appbrain.com/app/dungeon-defenders%3A-first-wave/com.trendy.ddapp

A guide on how to get this game to run on a Droid (where a custom ROM is require to get 256Mb of RAM free to run the game): http://www.forums.trendyent.com/showthread.php?447-How-to-play-Dungeon-Defenders-on-your- Motorola-Droid-Milestone-(requires-root)

How is this possible? Does anyone know what is going on here? Having access to that much RAM would make certain projects I'm working on much easier to write so I'm very interested to know what this game is doing.

rbcc
  • 2,452
  • 3
  • 26
  • 28

4 Answers4

1

On the droidcon in Berlin, Germany, I heard that you can't increase the amount of RAM an application can use on the dalvik side. You can use all available memory on the native side so I guess the named application have implemented heavy memory stuff native in C using the NDK. Thats the only possible solution I know...

Update It wasn't the conference, it was a Google Lab visit at my university with Reto Meier and colleagues.

WarrenFaith
  • 57,492
  • 25
  • 134
  • 150
  • "You can use all available memory on the native side". Are you sure about this? When you create Bitmap objects for example, Android keeps track of how much "native" memory you're using. If this is true, can't I just abuse this by writing an NDK function that allocates memory and passes it back to Java? What's to stop an app from using up all the available memory and making the system unstable? – rbcc Jan 23 '11 at 15:20
  • I never tried this (I can't write c/c++ code :/) so this is only what I heard. If I remember correctly it wasn't on a conference it was on a Google Lab event in my university with Reto Meier and his 3 friends. So I think this information should be solid. If someone can prove that with an example I would be very happy to see it. – WarrenFaith Jan 23 '11 at 16:22
  • Thanks for the info. I would be very interested in seeing code for this. For example, I make use of 2 large int arrays (for doing image processing effects) in Java at the moment. If I could allocate these in C somehow I could seriously reduce the memory footprint of my app. – rbcc Jan 23 '11 at 17:13
0

As far as i know Android is able to use more than 256MB of RAM since 2.2
However most phones shows less than they have, because there is always some Ram reserved for the system.

Beasly
  • 1,517
  • 4
  • 20
  • 30
  • I've getting "java.lang.OutOfMemoryError: bitmap size exceeds VM budget" errors when going over 24Mb on an HTC Desire running Android 2.2. Does you have any links with more info about your post? – rbcc Jan 23 '11 at 15:02
  • I mean overall system! I Also don't know how one app can access so much Ram. – Beasly Jan 23 '11 at 15:04
0

I'm using NDK for my app. and for my testing device when i take more than the 16mb limit (HTC magic, android 2.2) the app crashes and the system throws exceptions for invalid addresses access. So no, you can´t use all the memory you want neither from native side or from the java-managed side.

I've read about using different .so libraries and load them when running your app, but i dont know how it works or if its a viable workaround. Any suggestions?

Alexander Fradiani
  • 1,001
  • 3
  • 13
  • 33
  • Hmm, that's strange. The HTC Magic has 288Mb of RAM apparently. The emulator configured with less RAM doesn't crash for me when you use more than 16Mb. The invalid address exception sounds very strange. I would have thought you'd be getting an out of memory exception or null being returned by malloc. – rbcc Apr 04 '11 at 07:06
-1

If you do not need to render the image in real time, the answer is simple, just send the image to your server, with some image processing command, render it there, and send it back to Android. If your application requires >256MB RAM then you're going to severely limit a lot of your audience, and that's not good.

Lie Ryan
  • 62,238
  • 13
  • 100
  • 144
  • This solution only works if you can afford the bandwidth and CPU costs. My app doesn't need 256Mb of RAM by the way, only about 30 or 40 MB (about 30% over the typical limit). I've done some testing and it seems you can use this quite safely without risky crashes. – rbcc Apr 04 '11 at 07:04