Wieviel "Speicher" darf eine App mit new anfordern?

  • 1 Antworten
  • Letztes Antwortdatum
J

Johan

Dauer-User
256
folgender Code
Code:
class main_activity(...) {
    final static MEM_SIZE = 350*1024*1024; // 350 MByte
    ...
    public void func_needs_lot_of_memory(View view) {
        byte mem[];
        int i=1; // nur eingeführt, damit man darauf Breakpoint setzen kann
        mem = new byte[MEM_SIZE];
        mem[MEM_SIZE-1] = -1;
        mem = null;
        i=i+0; // Verhindert Warnung bei int i=1
        System.gc();
    }
}

App wird bei dieser Funktion beendet, ebenso bei 100*1024*1024, mit 10*1024*1024 funktioniert es.

Gibt es eine Obergrenze, wieviel RAM eine App anfordern darf?

Falls ja, würde das auch für eine native App gelten (C++)?
 
android - What is the maximum amount of RAM an app can use? - Stack Overflow

Das sollte deine Frage eigentlich exakt beantworten, inklusive dem Teil zu einer native app.

Hier gibts noch einiges an Info
Managing Your App's Memory | Android Developers

To maintain a functional multi-tasking environment, Android sets a hard limit on the heap size for each app. The exact heap size limit varies between devices based on how much RAM the device has available overall. If your app has reached the heap capacity and tries to allocate more memory, it will receive an OutOfMemoryError.

In some cases, you might want to query the system to determine exactly how much heap space you have available on the current device—for example, to determine how much data is safe to keep in a cache. You can query the system for this figure by calling getMemoryClass(). This returns an integer indicating the number of megabytes available for your app's heap. This is discussed further below, under Check how much memory you should use.
 
  • Danke
Reaktionen: Johan

Ähnliche Themen

G
Antworten
0
Aufrufe
132
Gerdchen07
G
G
Antworten
1
Aufrufe
384
Gerdchen07
G
G
Antworten
13
Aufrufe
598
Gerdchen07
G
L
Antworten
2
Aufrufe
554
Lexub
L
migi01
Antworten
26
Aufrufe
1.990
migi01
migi01
Zurück
Oben Unten