-2

based on Android Developers site:

Mobile devices typically have constrained system resources. Android devices can have as little as 16MB of memory available to a single application. The Android Compatibility Definition Document (CDD), Section 3.7. Virtual Machine Compatibility gives the required minimum application memory for various screen sizes and densities. Applications should be optimized to perform under this minimum memory limit. However, keep in mind many devices are configured with higher limits.

so maybe I develop an app which works on some devices but faces with out of memory error in other devices. how to get rid of this problem?

Soheil
  • 1,676
  • 7
  • 34
  • 65

2 Answers2

3

[humor] Change the laws of physics [/humor]

Seriously, you should use good programming techniques to minimize the amount of memory needed by your application (even on devices with plentiful memory) If necessary you can check the space available and limit the functionality of your application when resources on the device are limited: This may help with that task: How do I detect the heap size usage of an android application

Community
  • 1
  • 1
Dale Wilson
  • 9,166
  • 3
  • 34
  • 52
  • "good programming techniques" is a huge topic, by the way, that is better addressed in an undergrad programming course than in an SO question -- especially since we don't know what your app actually does. – Dale Wilson Dec 06 '13 at 20:18
2

How to solve these issues?

Well - you could easily solve this with exception-handling to avoid OutOfMemoryException.

Then you can also set heapsize to large in the manifest-file, that is:

  android:largeHeap="true"

But older android-version do not allow this

Björn Hallström
  • 3,775
  • 9
  • 39
  • 50
  • 1
    Exception handling isn't really solving the problem. If you manage to fill the heap so that just 1 byte is left you'll crash in any unrelated code that happens to require 2 bytes. And large heap is just delaying the problem if you don't write good code that is capable of managing restricted memory. – zapl Dec 06 '13 at 20:20
  • Yes - delaying the crash IF you have a memoryleak. – Björn Hallström Dec 06 '13 at 21:35