This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
i have a problem with a strange out of memory exception that only occurs on some devices (mostly HTC Desire). It happens there every time a user starts a certain activity (no matter how - there are two paths to that activity) and i'm really puzzled as to why (i checked for leaks and couldn't find any)...
The error is either thrown when calling setContentView or shortly after.
This is the code block that throws the error:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(DebugFlags.LOG_MEMORY)
{
MemoryAnalyser.logHeap(this.getClass());
}
setContentView(R.layout.activity_stats);
try
{
monthsAvailable = getMonthTimeStamps();
Spinner xSpin = (Spinner) findViewById(R.id.spinnerTimespan);
m_adapterForSpinner = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item);
m_adapterForSpinner.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
xSpin.setAdapter(m_adapterForSpinner);
for(Iterator<monthObject> i = monthsAvailable.iterator();i.hasNext();)
{
monthObject xObj = i.next();
String dateString = String.format("%1$te.%1$tm.%1$tY - %2$te.%2$tm.%2$tY", xObj.fromDate, xObj.toDate);
m_adapterForSpinner.add(dateString);
}
xSpin.setSelection(xSpin.getCount()-1);
xSpin.setOnItemSelectedListener(this);
//setupStatData(null, null);
checkStatsAvailable();
//throw(new java.lang.OutOfMemoryError());
}
catch(java.lang.OutOfMemoryError e)
{
MemoryAnalyser.dumpHeap();
MemoryAnalyser.logHeap(this.getClass());
Toast xToast = Toast.makeText(getApplicationContext(), "OutOfMemoryException - bitte Log und Datei com.eventkontor.networkcheck.hprof auf SD-Karte an Entwickler senden", 5000);
xToast.show();
this.finish();
}
if(DebugFlags.LOG_MEMORY)
{
MemoryAnalyser.logHeap(this.getClass());
}
}
as i said - the error is usually thrown when calling setContentView or when calling getMonthTimeStamps()
getMonthTimeStamps is a helper function which creates a list of dates available in the internal database. It creates a couple of (small objects) and returns an ArrayList. Here is the function
private ArrayList<monthObject> getMonthTimeStamps()
{
ArrayList<monthObject> dates = new ArrayList<monthObject>();
Cursor c = getContentResolver().query(CallLogTableMetaData.CONTENT_URI, new String[]{CallLogTableMetaData.CALLOG_DATE}, null, null, CallLogTableMetaData._ID + " asc");
try{
if(c.moveToFirst())
{
SharedPreferences prefs = Utils.getPreferences(this);
int resetDay = prefs.getInt("pref_callog_reset_day", 1);
prefs = null;
long starttime = c.getLong(0);
c.close();
c=null;
Date startDate = new Date(starttime);
GregorianCalendar today = new GregorianCalendar();
GregorianCalendar xCal = new GregorianCalendar();
xCal.setTime(startDate);
xCal.set(GregorianCalendar.DAY_OF_MONTH, resetDay);
while(xCal.before(today))
{
monthObject xObj = new monthObject();
xObj.setTimestamp(xCal.getTimeInMillis());
xObj.setFromDate(xCal.getTime());
xCal.add(GregorianCalendar.MONTH, 1);
xCal.set(GregorianCalendar.DAY_OF_MONTH, resetDay);
xCal.set(Calendar.HOUR_OF_DAY, 0);
xCal.set(Calendar.MINUTE, 0);
xCal.set(Calendar.SECOND, 0);
xCal.set(Calendar.MILLISECOND, 0);
xObj.setToDate(xCal.getTime());
xObj.setToTimestamp(xCal.getTimeInMillis());
dates.add(xObj);
xObj = null;
}
xCal = null;
today = null;
return dates;
}
else
{
return dates;
}
}
finally{
try
{
c.close();
}
catch(Exception e)
{
}
}
}
I'm not claiming that my code is flawless or perfect, but i really don't understand why this error is thrown. The XML-layout doesn't contain any references to images and not very complicated (textview, spinner, tablelayout).
Here is the error log i received from one user:
I/ActivityManager(16789): Starting activity: Intent { cmp=com.eventkontor.networkcheck/.StatActivity }
D/dalvikvm( 5053): GC freed 8267 objects / 556152 bytes in 45ms
D/dalvikvm( 5053): GC freed 1716 objects / 371240 bytes in 45ms
D/dalvikvm( 5053): GC freed 15 objects / 62936 bytes in 56ms
D/dalvikvm( 5053): GC freed 4 objects / 233856 bytes in 77ms
D/dalvikvm( 5053): GC freed 14 objects / 544 bytes in 83ms
W/ActivityManager(16789): Launch timeout has expired, giving up wake lock!
W/ActivityManager(16789): Activity idle timeout for HistoryRecord{46a4b878 com.eventkontor.networkcheck/.StatActivity}
D/dalvikvm( 5053): GC freed 3 objects / 210456 bytes in 107ms
D/dalvikvm( 5053): GC freed 3 objects / 315656 bytes in 118ms
D/dalvikvm( 5210): GC freed 7752 objects / 904320 bytes in 1116ms
D/dalvikvm( 5053): GC freed 2 objects / 48 bytes in 136ms
D/dalvikvm( 5053): GC freed 3 objects / 473448 bytes in 155ms
D/dalvikvm( 641): GC freed 4397 objects / 781024 bytes in 1246ms
D/dalvikvm( 5053): GC freed 2 objects / 48 bytes in 175ms
D/dalvikvm( 5053): GC freed 2 objects / 56 bytes in 203ms
I/dalvikvm-heap( 5053): Clamp target GC heap from 24.522MB to 24.000MB
D/dalvikvm( 5053): GC freed 3 objects / 710120 bytes in 207ms
I/dalvikvm-heap( 5053): Clamp target GC heap from 26.012MB to 24.000MB
D/dalvikvm( 5053): GC freed 2 objects / 56 bytes in 220ms
I/dalvikvm-heap( 5053): Clamp target GC heap from 24.012MB to 24.000MB
I/dalvikvm-heap( 5053): Grow heap (frag case) to 24.000MB for 16-byte allocation
I/dalvikvm-heap( 5053): Clamp target GC heap from 26.012MB to 24.000MB
D/dalvikvm( 5053): GC freed 0 objects / 0 bytes in 238ms
I/dalvikvm-heap( 5053): Forcing collection of SoftReferences for 24-byte allocation
I/dalvikvm-heap( 5053): Clamp target GC heap from 26.012MB to 24.000MB
D/dalvikvm( 5053): GC freed 0 objects / 0 bytes in 220ms
E/dalvikvm-heap( 5053): Out of memory on a 24-byte allocation.
I/dalvikvm( 5053): "HeapWorker" daemon prio=5 tid=5 RUNNABLE
I/dalvikvm( 5053): | group="system" sCount=0 dsCount=0 s=N obj=0x44e0eab8 self=0x14a298
I/dalvikvm( 5053): | sysTid=5054 nice=0 sched=0/0 cgrp=default handle=1351480
I/dalvikvm( 5053): at com.android.internal.os.BinderInternal$GcWatcher.finalize(BinderInternal.java:~48)
I/dalvikvm( 5053): at dalvik.system.NativeStart.run(Native Method)
I/dalvikvm( 5053):
E/dalvikvm( 5053): Out of memory: Heap Size=22791KB, Allocated=22204KB, Bitmap Size=1806KB
I/dalvikvm-heap( 5053): Clamp target GC heap from 26.012MB to 24.000MB
D/dalvikvm( 5053): GC freed 0 objects / 0 bytes in 291ms
I/dalvikvm-heap( 5053): Forcing collection of SoftReferences for 40-byte allocation
I/dalvikvm-heap( 5053): Clamp target GC heap from 26.012MB to 24.000MB
D/dalvikvm( 5053): GC freed 0 objects / 0 bytes in 220ms
E/dalvikvm-heap( 5053): Out of memory on a 40-byte allocation.
I/dalvikvm( 5053): "main" prio=5 tid=3 RUNNABLE
I/dalvikvm( 5053): | group="main" sCount=0 dsCount=0 s=N obj=0x4001b470 self=0xbdd0
I/dalvikvm( 5053): | sysTid=5053 nice=0 sched=0/0 cgrp=default handle=-1343993180
I/dalvikvm( 5053): at com.eventkontor.networkcheck.StatActivity.getMonthTimeStamps(StatActivity.java:~270)
I/dalvikvm( 5053): at com.eventkontor.networkcheck.StatActivity.onCreate(StatActivity.java:119)
I/dalvikvm( 5053): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
I/dalvikvm( 5053): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2544)
I/dalvikvm( 5053): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2621)
I/dalvikvm( 5053): at android.app.ActivityThread.access$2200(ActivityThread.java:126)
I/dalvikvm( 5053): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1932)
I/dalvikvm( 5053): at android.os.Handler.dispatchMessage(Handler.java:99)
I/dalvikvm( 5053): at android.os.Looper.loop(Looper.java:123)
I/dalvikvm( 5053): at android.app.ActivityThread.main(ActivityThread.java:4595)
I/dalvikvm( 5053): at java.lang.reflect.Method.invokeNative(Native Method)
I/dalvikvm( 5053): at java.lang.reflect.Method.invoke(Method.java:521)
I/dalvikvm( 5053): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
I/dalvikvm( 5053): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
I/dalvikvm( 5053): at dalvik.system.NativeStart.main(Native Method)
I/dalvikvm( 5053):
E/dalvikvm( 5053): Out of memory: Heap Size=22791KB, Allocated=22204KB, Bitmap Size=1806KB
I/dalvikvm-heap( 5053): Clamp target GC heap from 26.012MB to 24.000MB
D/dalvikvm( 5053): GC freed 0 objects / 0 bytes in 231ms
I/dalvikvm-heap( 5053): Forcing collection of SoftReferences for 24-byte allocation
I/dalvikvm-heap( 5053): Clamp target GC heap from 26.012MB to 24.000MB
D/dalvikvm( 5053): GC freed 0 objects / 0 bytes in 220ms
E/dalvikvm-heap( 5053): Out of memory on a 24-byte allocation.
I/dalvikvm( 5053): "HeapWorker" daemon prio=5 tid=5 RUNNABLE
I/dalvikvm( 5053): | group="system" sCount=0 dsCount=0 s=N obj=0x44e0eab8 self=0x14a298
I/dalvikvm( 5053): | sysTid=5054 nice=0 sched=0/0 cgrp=default handle=1351480
I/dalvikvm( 5053): at com.android.internal.os.BinderInternal$GcWatcher.finalize(BinderInternal.java:~48)
I/dalvikvm( 5053): at dalvik.system.NativeStart.run(Native Method)
I/dalvikvm( 5053):
E/dalvikvm( 5053): Out of memory: Heap Size=22791KB, Allocated=22204KB, Bitmap Size=1806KB
I/dalvikvm-heap( 5053): Clamp target GC heap from 26.012MB to 24.000MB
I/dalvikvm( 5053): Uncaught exception thrown by finalizer (will be discarded):
I/dalvikvm( 5053): Ljava/lang/OutOfMemoryError;: [memory exhausted]
I/dalvikvm( 5053): at dalvik.system.NativeStart.main(Native Method)
D/dalvikvm( 5053): GC freed 0 objects / 0 bytes in 237ms
I/dalvikvm-heap( 5053): Forcing collection of SoftReferences for 24-byte allocation
I/dalvikvm-heap( 5053): Clamp target GC heap from 26.012MB to 24.000MB
D/dalvikvm( 5053): GC freed 1 objects / 16 bytes in 220ms
E/dalvikvm-heap( 5053): Out of memory on a 24-byte allocation.
I/dalvikvm( 5053): "main" prio=5 tid=3 RUNNABLE
I/dalvikvm( 5053): | group="main" sCount=0 dsCount=0 s=N obj=0x4001b470 self=0xbdd0
I/dalvikvm( 5053): | sysTid=5053 nice=0 sched=0/0 cgrp=default handle=-1343993180
I/dalvikvm( 5053): at com.eventkontor.networkcheck.StatActivity.getMonthTimeStamps(StatActivity.java:~270)
I/dalvikvm( 5053): at com.eventkontor.networkcheck.StatActivity.onCreate(StatActivity.java:119)
I/dalvikvm( 5053): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
I/dalvikvm( 5053): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2544)
I/dalvikvm( 5053): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2621)
I/dalvikvm( 5053): at android.app.ActivityThread.access$2200(ActivityThread.java:126)
I/dalvikvm( 5053): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1932)
I/dalvikvm( 5053): at android.os.Handler.dispatchMessage(Handler.java:99)
I/dalvikvm( 5053): at android.os.Looper.loop(Looper.java:123)
I/dalvikvm( 5053): at android.app.ActivityThread.main(ActivityThread.java:4595)
I/dalvikvm( 5053): at java.lang.reflect.Method.invokeNative(Native Method)
I/dalvikvm( 5053): at java.lang.reflect.Method.invoke(Method.java:521)
I/dalvikvm( 5053): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
I/dalvikvm( 5053): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
I/dalvikvm( 5053): at dalvik.system.NativeStart.main(Native Method)
I/dalvikvm( 5053):
E/dalvikvm( 5053): Out of memory: Heap Size=22791KB, Allocated=22204KB, Bitmap Size=1806KB
I/dalvikvm-heap( 5053): Clamp target GC heap from 26.011MB to 24.000MB
D/dalvikvm( 5053): GC freed 11 objects / 728 bytes in 221ms
I/dalvikvm-heap( 5053): Clamp target GC heap from 24.011MB to 24.000MB
I/dalvikvm-heap( 5053): Grow heap (frag case) to 24.000MB for 24-byte allocation
I/dalvikvm-heap( 5053): Clamp target GC heap from 26.011MB to 24.000MB
D/dalvikvm( 5053): GC freed 0 objects / 0 bytes in 221ms
I/dalvikvm-heap( 5053): Clamp target GC heap from 24.011MB to 24.000MB
I/dalvikvm-heap( 5053): Grow heap (frag case) to 24.000MB for 136-byte allocation
I/dalvikvm-heap( 5053): Clamp target GC heap from 26.011MB to 24.000MB
D/dalvikvm( 5053): GC freed 0 objects / 0 bytes in 219ms
I/dalvikvm-heap( 5053): Clamp target GC heap from 24.011MB to 24.000MB
I/dalvikvm-heap( 5053): Grow heap (frag case) to 24.000MB for 24-byte allocation
I/dalvikvm-heap( 5053): Clamp target GC heap from 26.011MB to 24.000MB
D/dalvikvm( 5053): GC freed 0 objects / 0 bytes in 220ms
I/dalvikvm-heap( 5053): Clamp target GC heap from 24.011MB to 24.000MB
I/dalvikvm-heap( 5053): Grow heap (frag case) to 24.000MB for 54-byte allocation
I/dalvikvm-heap( 5053): Clamp target GC heap from 26.011MB to 24.000MB
D/dalvikvm( 5053): GC freed 4 objects / 272 bytes in 221ms
I/dalvikvm-heap( 5053): Clamp target GC heap from 24.011MB to 24.000MB
I/dalvikvm-heap( 5053): Grow heap (frag case) to 24.000MB for 24-byte allocation
I/dalvikvm-heap( 5053): Clamp target GC heap from 26.011MB to 24.000MB
D/dalvikvm( 5053): GC freed 0 objects / 0 bytes in 240ms
I/dalvikvm-heap( 5053): Clamp target GC heap from 24.011MB to 24.000MB
I/dalvikvm-heap( 5053): Grow heap (frag case) to 24.000MB for 68-byte allocation
D/dalvikvm( 5053): GC freed 589340 objects / 19930400 bytes in 180ms
I/dalvikvm( 5053): hprof: dumping VM heap to "/sdcard/com.eventkontor.networkcheck.hprof-hptemp".
I/dalvikvm( 5053): hprof: dumping heap strings to "/sdcard/com.eventkontor.networkcheck.hprof".
I/dalvikvm( 5053): hprof: heap dump completed, temp file removed
D/dalvikvm( 5053): GC freed 8 objects / 616 bytes in 1056ms
D/NetworkCheck( 5053): debug. =================================
D/NetworkCheck( 5053): debug.heap native: allocated 5,81MB of 6,94MB (0,61MB free) in [com.eventkontor.networkcheck.StatActivity]
D/NetworkCheck( 5053): debug.memory: allocated: 22,00MB of 24,00MB (19,00MB free)
D/dalvikvm( 5053): GC freed 148 objects / 7608 bytes in 34ms
D/dalvikvm( 5053): GC freed 5 objects / 264 bytes in 33ms
E/dalvikvm-heap( 5053): 32980-byte external allocation too large for this process.
E/dalvikvm( 5053): Out of memory: Heap Size=22791KB, Allocated=2743KB, Bitmap Size=1806KB
E/ ( 5053): VM won't let us allocate 32980 bytes
D/skia ( 5053): --- decoder->decode returned false
D/AndroidRuntime( 5053): Shutting down VM
W/dalvikvm( 5053): threadid=3: thread exiting with uncaught exception (group=0x4001b390)
D/UNHANDLED_EXCEPTION( 5053): Writing unhandled exception to: /data/data/com.eventkontor.networkcheck/files/1.5-55980.stacktrace
I/global ( 5053): Default buffer size used in BufferedWriter constructor. It would be better to be explicit if an 8k-char buffer is required.
D/UNHANDLED_EXCEPTION( 5053): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.eventkontor.networkcheck/com.eventkontor.networkcheck.StatActivity}: android.view.InflateException: Binary XML file line #21: Error inflating class <unknown>
D/UNHANDLED_EXCEPTION( 5053): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2596)
D/UNHANDLED_EXCEPTION( 5053): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2621)
D/UNHANDLED_EXCEPTION( 5053): at android.app.ActivityThread.access$2200(ActivityThread.java:126)
D/UNHANDLED_EXCEPTION( 5053): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1932)
D/UNHANDLED_EXCEPTION( 5053): at android.os.Handler.dispatchMessage(Handler.java:99)
D/UNHANDLED_EXCEPTION( 5053): at android.os.Looper.loop(Looper.java:123)
D/UNHANDLED_EXCEPTION( 5053): at android.app.ActivityThread.main(ActivityThread.java:4595)
D/UNHANDLED_EXCEPTION( 5053): at java.lang.reflect.Method.invokeNative(Native Method)
D/UNHANDLED_EXCEPTION( 5053): at java.lang.reflect.Method.invoke(Method.java:521)
D/UNHANDLED_EXCEPTION( 5053): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
D/UNHANDLED_EXCEPTION( 5053): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
D/UNHANDLED_EXCEPTION( 5053): at dalvik.system.NativeStart.main(Native Method)
D/UNHANDLED_EXCEPTION( 5053): Caused by: android.view.InflateException: Binary XML file line #21: Error inflating class <unknown>
D/UNHANDLED_EXCEPTION( 5053): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
D/UNHANDLED_EXCEPTION( 5053): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
D/UNHANDLED_EXCEPTION( 5053): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
D/UNHANDLED_EXCEPTION( 5053): at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
D/UNHANDLED_EXCEPTION( 5053): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
D/UNHANDLED_EXCEPTION( 5053): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
D/UNHANDLED_EXCEPTION( 5053): at android.widget.Toast.makeText(Toast.java:235)
D/UNHANDLED_EXCEPTION( 5053): at com.eventkontor.networkcheck.StatActivity.onCreate(StatActivity.java:140)
D/UNHANDLED_EXCEPTION( 5053): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
D/UNHANDLED_EXCEPTION( 5053): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2544)
D/UNHANDLED_EXCEPTION( 5053): ... 11 more
D/UNHANDLED_EXCEPTION( 5053): Caused by: java.lang.reflect.InvocationTargetException
D/UNHANDLED_EXCEPTION( 5053): at android.widget.LinearLayout.<init>(LinearLayout.java:92)
D/UNHANDLED_EXCEPTION( 5053): at java.lang.reflect.Constructor.constructNative(Native Method)
D/UNHANDLED_EXCEPTION( 5053): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
D/UNHANDLED_EXCEPTION( 5053): at android.view.LayoutInflater.createView(LayoutInflater.java:500)
D/UNHANDLED_EXCEPTION( 5053): ... 20 more
D/UNHANDLED_EXCEPTION( 5053): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
D/UNHANDLED_EXCEPTION( 5053): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
D/UNHANDLED_EXCEPTION( 5053): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:464)
D/UNHANDLED_EXCEPTION( 5053): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:340)
D/UNHANDLED_EXCEPTION( 5053): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
D/UNHANDLED_EXCEPTION( 5053): at android.content.res.Resources.loadDrawable(Resources.java:1705)
D/UNHANDLED_EXCEPTION( 5053): at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
D/UNHANDLED_EXCEPTION( 5053): at android.view.View.<init>(View.java:1850)
D/UNHANDLED_EXCEPTION( 5053): at android.view.View.<init>(View.java:1799)
D/UNHANDLED_EXCEPTION( 5053): at android.view.ViewGroup.<init>(ViewGroup.java:296)
D/UNHANDLED_EXCEPTION( 5053): ... 24 more
Thanks
Andreas
It was an infinite loop caused by GregorianCalendar not incrementing the date. Still investigating the issue, but this one has been resolved.
Just reading the stacktrace you problem seems to be of you trying to load some bitmap. That is stated as a root cause Are you loading bunch of images? That exception prevents inflating of your layout. You need ether cache or reduce size of your images.
Look and debug through these
D/UNHANDLED_EXCEPTION( 5053): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
D/UNHANDLED_EXCEPTION( 5053): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
D/UNHANDLED_EXCEPTION( 5053): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:464)
D/UNHANDLED_EXCEPTION( 5053): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:340)
D/UNHANDLED_EXCEPTION( 5053): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
D/UNHANDLED_EXCEPTION( 5053): at android.content.res.Resources.loadDrawable(Resources.java:1705)
D/UNHANDLED_EXCEPTION( 5053): at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
D/UNHANDLED_EXCEPTION( 5053): at android.view.View.<init>(View.java:1850)
D/UNHANDLED_EXCEPTION( 5053): at android.view.View.<init>(View.java:1799)
D/UNHANDLED_EXCEPTION( 5053): at android.view.ViewGroup.<init>(ViewGroup.java:296)
Have you looked at related questions? Here's a relevant SO search. A few of these point back to this answer on using the BitmapFactory class. This approach down-samples each of the images to reduce their impact on memory. Hope it helps.
Related
I'm working on a stress testing tool, one of designed scenario is to use up memory, and leave only a few mega for the app under test and others.
By searching internet about this topic, I learned that Android Dalvik vm limit program allocation in 16MB, 24MB, or 32MB. But I do realized some app can retain up to 80 MB memory. So is that idea reasonable? if so, how to achieve that goal.
thanks in advance,
Forrest
I would use one or several services to consume memory.
This article tells us that Leaving a service running when it’s not needed is one of the worst memory-management mistakes:
https://developer.android.com/training/articles/memory.html#Services
and this one tells us which process is killed last:
http://developer.android.com/guide/components/processes-and-threads.html#Lifecycle
In addition, I would use a foreground activity to cause killing the app under test (and see if the data survive): when the memory is already allocated to services, a foreground activity would cause killing of the background activities.
Android is a Linux, so you can use stuff like /proc/$PID/maps (see here).
It's interesting to know what you will use, so please answer your own question after you solve the problem.
thanks following up with me. Now I believe I get an answer to this question.
Generally speaking, we cannot rely on one app/service to use up the whole system RAM. Andoid app runs in Dalvik vm and there's an upper limit for each application or service. It's also known as maximum heap size limit. Different phones has different limit heap size:
HUAWEI U9508: 256MB android 4.0.4
Meizu MX3: 192MB android 4.2.1* ll
We can get this heap size by code:
Runtime.getRuntime().maxMemory();
Android Service fall into this rule as well, the heap size limit is the same as normal app.
Initially, android os give the app a relatively small heap, when the app reach the capacity, memory manager will grow the heap size automatically. Later, if app reaches the heap size limit, you'll get OutOfMemoryError. See below log(copy to text editor for better reading):
02-15 09:22:25.438: D/dalvikvm(9992): GC_FOR_ALLOC freed 140K, 11% free 2943K/3280K, paused 11ms, total 11ms
02-15 09:22:25.478: I/dalvikvm-heap(9992): Grow heap (frag case) to 27.059MB for 25165840-byte allocation
02-15 09:22:25.478: D/dalvikvm(9992): threadid=1: still suspended after undo (sc=1 dc=1)
02-15 09:22:25.488: D/dalvikvm(9992): threadid=1: still suspended after undo (sc=1 dc=1)
02-15 09:22:25.488: D/dalvikvm(9992): GC_CONCURRENT freed 15K, 2% free 27504K/27860K, paused 1ms+2ms, total 13ms
02-15 09:22:25.488: D/dalvikvm(9992): WAIT_FOR_CONCURRENT_GC blocked 12ms
02-15 09:22:43.758: I/Choreographer(9992): Skipped 1100 frames! The application may be doing too much work on its main thread.
02-15 09:22:43.913: D/dalvikvm(9992): GC_FOR_ALLOC freed 2K, 2% free 27504K/27856K, paused 25ms, total 25ms
02-15 09:22:43.963: I/dalvikvm-heap(9992): Grow heap (frag case) to 51.044MB for 25165840-byte allocation
02-15 09:22:43.978: D/dalvikvm(9992): GC_FOR_ALLOC freed <1K, 1% free 52080K/52436K, paused 14ms, total 14ms
02-15 09:22:43.998: D/dalvikvm(9992): GC_CONCURRENT freed <1K, 1% free 52080K/52436K, paused 2ms+4ms, total 21ms
02-15 09:22:52.578: D/dalvikvm(9992): GC_FOR_ALLOC freed 4K, 1% free 52080K/52432K, paused 12ms, total 12ms
02-15 09:22:52.613: I/dalvikvm-heap(9992): Grow heap (frag case) to 75.044MB for 25165840-byte allocation
02-15 09:22:52.633: D/dalvikvm(9992): GC_CONCURRENT freed 0K, 1% free 76656K/77012K, paused 3ms+4ms, total 20ms
02-15 09:22:52.633: D/dalvikvm(9992): WAIT_FOR_CONCURRENT_GC blocked 17ms
02-15 09:22:52.633: D/dalvikvm(9992): WAIT_FOR_CONCURRENT_GC blocked 17ms
02-15 09:22:55.198: D/dalvikvm(9992): GC_FOR_ALLOC freed 1K, 1% free 76656K/77012K, paused 13ms, total 13ms
02-15 09:22:55.233: I/dalvikvm-heap(9992): Grow heap (frag case) to 99.044MB for 25165840-byte allocation
02-15 09:22:55.253: D/dalvikvm(9992): GC_CONCURRENT freed 0K, 1% free 101232K/101592K, paused 1ms+5ms, total 17ms
02-15 09:22:55.253: D/dalvikvm(9992): WAIT_FOR_CONCURRENT_GC blocked 17ms
02-15 09:22:55.253: D/dalvikvm(9992): WAIT_FOR_CONCURRENT_GC blocked 17ms
02-15 09:22:56.438: D/dalvikvm(9992): GC_FOR_ALLOC freed <1K, 1% free 101232K/101592K, paused 17ms, total 17ms
02-15 09:22:56.478: I/dalvikvm-heap(9992): Grow heap (frag case) to 123.044MB for 25165840-byte allocation
02-15 09:22:56.493: D/dalvikvm(9992): GC_FOR_ALLOC freed 0K, 1% free 125808K/126172K, paused 18ms, total 18ms
02-15 09:22:56.523: D/dalvikvm(9992): GC_CONCURRENT freed <1K, 1% free 125808K/126172K, paused 2ms+7ms, total 27ms
02-15 09:22:57.458: D/dalvikvm(9992): GC_FOR_ALLOC freed <1K, 1% free 125808K/126172K, paused 17ms, total 18ms
02-15 09:22:57.493: I/dalvikvm-heap(9992): Grow heap (frag case) to 147.044MB for 25165840-byte allocation
02-15 09:22:57.513: D/dalvikvm(9992): GC_FOR_ALLOC freed 0K, 1% free 150384K/150752K, paused 18ms, total 18ms
02-15 09:22:57.543: D/dalvikvm(9992): GC_CONCURRENT freed <1K, 1% free 150384K/150752K, paused 3ms+7ms, total 29ms
02-15 09:22:58.668: D/dalvikvm(9992): GC_FOR_ALLOC freed <1K, 1% free 150384K/150752K, paused 17ms, total 17ms
02-15 09:22:58.708: I/dalvikvm-heap(9992): Grow heap (frag case) to 171.044MB for 25165840-byte allocation
02-15 09:22:58.733: D/dalvikvm(9992): GC_FOR_ALLOC freed 0K, 1% free 174960K/175332K, paused 24ms, total 24ms
02-15 09:22:58.768: D/dalvikvm(9992): GC_CONCURRENT freed <1K, 1% free 174960K/175332K, paused 2ms+11ms, total 36ms
02-15 09:22:59.718: D/dalvikvm(9992): GC_FOR_ALLOC freed <1K, 1% free 174960K/175332K, paused 35ms, total 35ms
02-15 09:22:59.718: I/dalvikvm-heap(9992): Forcing collection of SoftReferences for 25165840-byte allocation
02-15 09:22:59.778: D/dalvikvm(9992): GC_BEFORE_OOM freed 10K, 1% free 174950K/175332K, paused 58ms, total 58ms
02-15 09:22:59.778: E/dalvikvm-heap(9992): Out of memory on a 25165840-byte allocation.
02-15 09:22:59.778: I/dalvikvm(9992): "main" prio=5 tid=1 RUNNABLE
02-15 09:22:59.778: I/dalvikvm(9992): | group="main" sCount=0 dsCount=0 obj=0x40dd19a0 self=0x40bc6010
02-15 09:22:59.778: I/dalvikvm(9992): | sysTid=9992 nice=0 sched=0/0 cgrp=apps handle=1074504668
02-15 09:22:59.778: I/dalvikvm(9992): | state=R schedstat=( 0 0 0 ) utm=295 stm=49 core=0
02-15 09:22:59.778: I/dalvikvm(9992): at com.jdmobile.stresstestingutility.MainActivity$2.onClick(MainActivity.java:~148)
02-15 09:22:59.778: I/dalvikvm(9992): at android.view.View.performClick(View.java:4203)
02-15 09:22:59.778: I/dalvikvm(9992): at android.view.View$PerformClick.run(View.java:17556)
02-15 09:22:59.778: I/dalvikvm(9992): at android.os.Handler.handleCallback(Handler.java:725)
02-15 09:22:59.778: I/dalvikvm(9992): at android.os.Handler.dispatchMessage(Handler.java:92)
02-15 09:22:59.778: I/dalvikvm(9992): at android.os.Looper.loop(Looper.java:137)
02-15 09:22:59.778: I/dalvikvm(9992): at android.app.ActivityThread.main(ActivityThread.java:5105)
02-15 09:22:59.778: I/dalvikvm(9992): at java.lang.reflect.Method.invokeNative(Native Method)
02-15 09:22:59.778: I/dalvikvm(9992): at java.lang.reflect.Method.invoke(Method.java:511)
02-15 09:22:59.778: I/dalvikvm(9992): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-15 09:22:59.778: I/dalvikvm(9992): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-15 09:22:59.778: I/dalvikvm(9992): at dalvik.system.NativeStart.main(Native Method)
02-15 09:23:52.643: D/AndroidRuntime(9992): Shutting down VM
The other memory allocation limit is a chunk of memory(no fragment): 16MB, 24MB, or bigger, see this piece of code demonstration, ActivityManager:
/**
* Return the approximate per-application memory class of the current
* device. This gives you an idea of how hard a memory limit you should
* impose on your application to let the overall system work best. The
* returned value is in megabytes; the baseline Android memory class is
* 16 (which happens to be the Java heap limit of those devices); some
* device with more memory may return 24 or even higher numbers.
*/
public int getMemoryClass() {
return staticGetMemoryClass();
}
I'm having a weird issue.
I've created an app which works fine on a Samsung Galaxy S2 (heap size 48MB) but when I test it on a Motorola Xoom (heap size also 48MB) it exits with an OutOfMemory error.
This is particularly strange since from what I can tell I'm only actually loading about 20MB of data into the heap.
The crash occurs at the same place every time, it's when I'm loading the dictionary file into a Vector (the app is a word-game, and the dictionary file that is being loaded is about 2MB and resides in the assets folder). The dictionary makes it about as far as the words starting with R and then gives up the ghost.
The Samsung is running Android 2.2 and the Xoom is running 4.0.3
Here's the code which loads the dictionary:
public class Dictionary {
Vector words = new Vector();
public Dictionary() {
}
public void loadWords(String dFile) {
try {
InputStream is = AndroidFileIO.assets.open(dFile);
BufferedReader f = new BufferedReader(new InputStreamReader(is), 8192);
String word = null;
if (is != null) {
while ((word = f.readLine()) != null) {
words.addElement(word.toUpperCase());
}
}
is.close();
f = null;
} catch (Exception e) {
System.err.println("Unable to read from " + dFile);
// continue with empty dictionary
}
}
...and here's the LogCat output:
01-27 17:16:12.750: D/dalvikvm(9050): GC_FOR_ALLOC freed 63K, 4% free 6529K/6787K, paused 53ms
01-27 17:16:12.760: I/dalvikvm-heap(9050): Grow heap (frag case) to 8.383MB for 2048016-byte allocation
01-27 17:16:12.810: D/dalvikvm(9050): GC_CONCURRENT freed <1K, 4% free 8529K/8839K, paused 2ms+8ms
01-27 17:16:12.870: D/dalvikvm(9050): GC_FOR_ALLOC freed 20K, 4% free 8543K/8839K, paused 25ms
01-27 17:16:12.890: I/dalvikvm-heap(9050): Grow heap (frag case) to 12.302MB for 4096016-byte allocation
01-27 17:16:12.940: D/dalvikvm(9050): GC_FOR_ALLOC freed 0K, 3% free 12543K/12871K, paused 24ms
01-27 17:16:12.980: D/dalvikvm(9050): GC_CONCURRENT freed <1K, 3% free 12543K/12871K, paused 3ms+3ms
01-27 17:16:13.350: D/libEGL(9050): loaded /system/lib/egl/libGLES_android.so
01-27 17:16:13.360: D/libEGL(9050): loaded /system/lib/egl/libEGL_tegra.so
01-27 17:16:13.390: D/libEGL(9050): loaded /system/lib/egl/libGLESv1_CM_tegra.so
01-27 17:16:13.400: D/libEGL(9050): loaded /system/lib/egl/libGLESv2_tegra.so
01-27 17:16:13.440: D/OpenGLRenderer(9050): Enabling debug mode 0
01-27 17:16:13.840: D/dalvikvm(9050): GC_FOR_ALLOC freed 11K, 1% free 14001K/14087K, paused 20ms
01-27 17:16:13.890: D/dalvikvm(9050): GC_CONCURRENT freed 1K, 1% free 16000K/16135K, paused 2ms+3ms
01-27 17:16:13.990: D/dalvikvm(9050): GC_FOR_ALLOC freed <1K, 1% free 16001K/16135K, paused 19ms
01-27 17:16:14.000: I/dalvikvm-heap(9050): Grow heap (frag case) to 19.585MB for 4096016-byte allocation
01-27 17:16:14.060: D/dalvikvm(9050): GC_CONCURRENT freed <1K, 1% free 20001K/20167K, paused 1ms+20ms
01-27 17:16:14.370: D/dalvikvm(9050): GC_FOR_ALLOC freed <1K, 1% free 20001K/20167K, paused 17ms
01-27 17:16:14.380: I/dalvikvm-heap(9050): Grow heap (frag case) to 21.540MB for 2048016-byte allocation
01-27 17:16:14.420: D/dalvikvm(9050): GC_CONCURRENT freed <1K, 1% free 22001K/22215K, paused 2ms+3ms
01-27 17:16:14.510: D/dalvikvm(9050): GC_FOR_ALLOC freed <1K, 1% free 22001K/22215K, paused 17ms
01-27 17:16:14.520: I/dalvikvm-heap(9050): Grow heap (frag case) to 25.446MB for 4096016-byte allocation
01-27 17:16:14.540: D/dalvikvm(9050): GC_CONCURRENT freed <1K, 1% free 26001K/26247K, paused 2ms+3ms
01-27 17:16:14.840: D/dalvikvm(9050): GC_FOR_ALLOC freed <1K, 1% free 26001K/26247K, paused 20ms
01-27 17:16:14.840: I/dalvikvm-heap(9050): Grow heap (frag case) to 27.399MB for 2048016-byte allocation
01-27 17:16:14.870: D/dalvikvm(9050): GC_CONCURRENT freed <1K, 2% free 28001K/28295K, paused 1ms+3ms
01-27 17:16:15.070: D/dalvikvm(9050): GC_FOR_ALLOC freed <1K, 2% free 28389K/28743K, paused 20ms
01-27 17:16:15.080: I/dalvikvm-heap(9050): Grow heap (frag case) to 31.683MB for 4096016-byte allocation
01-27 17:16:15.130: D/dalvikvm(9050): GC_CONCURRENT freed <1K, 2% free 32388K/32775K, paused 2ms+3ms
01-27 17:16:15.220: D/dalvikvm(9050): GC_FOR_ALLOC freed 1K, 2% free 32390K/32775K, paused 19ms
01-27 17:16:15.220: I/dalvikvm-heap(9050): Grow heap (frag case) to 35.591MB for 4096016-byte allocation
01-27 17:16:15.260: D/dalvikvm(9050): GC_CONCURRENT freed <1K, 2% free 36390K/36807K, paused 1ms+4ms
01-27 17:16:16.510: D/dalvikvm(9050): GC_CONCURRENT freed 554K, 2% free 37925K/38535K, paused 2ms+5ms
01-27 17:16:16.940: D/dalvikvm(9050): GC_CONCURRENT freed 1047K, 3% free 38914K/40071K, paused 2ms+6ms
01-27 17:16:17.150: D/dalvikvm(9050): GC_CONCURRENT freed 982K, 3% free 39891K/41031K, paused 2ms+8ms
01-27 17:16:17.430: D/dalvikvm(9050): GC_CONCURRENT freed 1012K, 3% free 40876K/42055K, paused 2ms+8ms
01-27 17:16:17.770: D/dalvikvm(9050): GC_FOR_ALLOC freed 997K, 3% free 41820K/43015K, paused 65ms
01-27 17:16:18.100: D/dalvikvm(9050): GC_FOR_ALLOC freed 989K, 3% free 42757K/43975K, paused 75ms
01-27 17:16:18.480: D/dalvikvm(9050): GC_FOR_ALLOC freed 950K, 3% free 43636K/44871K, paused 81ms
01-27 17:16:18.780: D/dalvikvm(9050): GC_FOR_ALLOC freed 940K, 3% free 44525K/45767K, paused 84ms
01-27 17:16:19.130: D/dalvikvm(9050): GC_FOR_ALLOC freed 946K, 3% free 45421K/46663K, paused 94ms
01-27 17:16:19.410: D/dalvikvm(9050): GC_FOR_ALLOC freed 905K, 3% free 46303K/47559K, paused 99ms
01-27 17:16:19.770: I/dalvikvm-heap(9050): Clamp target GC heap from 48.105MB to 48.000MB
01-27 17:16:19.770: D/dalvikvm(9050): GC_FOR_ALLOC freed 897K, 3% free 47157K/48455K, paused 106ms
01-27 17:16:20.050: I/dalvikvm-heap(9050): Clamp target GC heap from 48.855MB to 48.000MB
01-27 17:16:20.050: D/dalvikvm(9050): GC_FOR_ALLOC freed 793K, 3% free 47924K/49159K, paused 112ms
01-27 17:16:20.220: I/dalvikvm-heap(9050): Clamp target GC heap from 49.239MB to 48.000MB
01-27 17:16:20.220: D/dalvikvm(9050): GC_FOR_ALLOC freed 396K, 2% free 48317K/49159K, paused 112ms
01-27 17:16:20.360: I/dalvikvm-heap(9050): Clamp target GC heap from 49.439MB to 48.000MB
01-27 17:16:20.360: D/dalvikvm(9050): GC_FOR_ALLOC freed 206K, 2% free 48523K/49159K, paused 109ms
01-27 17:16:20.480: I/dalvikvm-heap(9050): Clamp target GC heap from 49.541MB to 48.000MB
01-27 17:16:20.480: D/dalvikvm(9050): GC_FOR_ALLOC freed 104K, 2% free 48626K/49159K, paused 107ms
01-27 17:16:20.600: I/dalvikvm-heap(9050): Clamp target GC heap from 49.592MB to 48.000MB
01-27 17:16:20.600: D/dalvikvm(9050): GC_FOR_ALLOC freed 53K, 1% free 48679K/49159K, paused 111ms
01-27 17:16:20.720: I/dalvikvm-heap(9050): Clamp target GC heap from 49.618MB to 48.000MB
01-27 17:16:20.730: D/dalvikvm(9050): GC_FOR_ALLOC freed 26K, 1% free 48706K/49159K, paused 117ms
01-27 17:16:20.830: I/dalvikvm-heap(9050): Clamp target GC heap from 49.628MB to 48.000MB
01-27 17:16:20.830: D/dalvikvm(9050): GC_FOR_ALLOC freed 11K, 1% free 48717K/49159K, paused 105ms
01-27 17:16:20.950: I/dalvikvm-heap(9050): Clamp target GC heap from 49.631MB to 48.000MB
01-27 17:16:20.950: D/dalvikvm(9050): GC_FOR_ALLOC freed 2K, 1% free 48719K/49159K, paused 114ms
01-27 17:16:21.060: I/dalvikvm-heap(9050): Clamp target GC heap from 49.633MB to 48.000MB
01-27 17:16:21.060: D/dalvikvm(9050): GC_FOR_ALLOC freed 1K, 1% free 48721K/49159K, paused 112ms
01-27 17:16:21.170: I/dalvikvm-heap(9050): Clamp target GC heap from 49.636MB to 48.000MB
01-27 17:16:21.170: D/dalvikvm(9050): GC_FOR_ALLOC freed 3K, 1% free 48724K/49159K, paused 108ms
01-27 17:16:21.170: I/dalvikvm-heap(9050): Forcing collection of SoftReferences for 176-byte allocation
01-27 17:16:21.300: I/dalvikvm-heap(9050): Clamp target GC heap from 49.628MB to 48.000MB
01-27 17:16:21.300: D/dalvikvm(9050): GC_BEFORE_OOM freed 9K, 1% free 48715K/49159K, paused 127ms
01-27 17:16:21.410: I/dalvikvm-heap(9050): Clamp target GC heap from 49.635MB to 48.000MB
01-27 17:16:21.410: D/dalvikvm(9050): GC_FOR_ALLOC freed 8K, 1% free 48722K/49159K, paused 108ms
01-27 17:16:21.520: I/dalvikvm-heap(9050): Clamp target GC heap from 49.639MB to 48.000MB
01-27 17:16:21.520: D/dalvikvm(9050): GC_FOR_ALLOC freed 4K, 1% free 48727K/49159K, paused 109ms
01-27 17:16:21.620: I/dalvikvm-heap(9050): Clamp target GC heap from 49.641MB to 48.000MB
01-27 17:16:21.620: D/dalvikvm(9050): GC_FOR_ALLOC freed 2K, 1% free 48729K/49159K, paused 109ms
01-27 17:16:21.730: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:21.730: D/dalvikvm(9050): GC_FOR_ALLOC freed 1K, 1% free 48730K/49159K, paused 105ms
01-27 17:16:21.840: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:21.840: D/dalvikvm(9050): GC_FOR_ALLOC freed <1K, 1% free 48730K/49159K, paused 110ms
01-27 17:16:21.950: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:21.950: D/dalvikvm(9050): GC_FOR_ALLOC freed <1K, 1% free 48730K/49159K, paused 106ms
01-27 17:16:22.050: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:22.050: D/dalvikvm(9050): GC_FOR_ALLOC freed 0K, 1% free 48730K/49159K, paused 106ms
01-27 17:16:22.050: I/dalvikvm-heap(9050): Forcing collection of SoftReferences for 44-byte allocation
01-27 17:16:22.170: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:22.170: D/dalvikvm(9050): GC_BEFORE_OOM freed 0K, 1% free 48730K/49159K, paused 119ms
01-27 17:16:22.170: E/dalvikvm-heap(9050): Out of memory on a 44-byte allocation.
01-27 17:16:22.170: I/dalvikvm(9050): "Thread-1489" prio=5 tid=13 RUNNABLE
01-27 17:16:22.170: I/dalvikvm(9050): | group="main" sCount=0 dsCount=0 obj=0x417e7bd8 self=0x1a6a168
01-27 17:16:22.170: I/dalvikvm(9050): | sysTid=9119 nice=0 sched=0/0 cgrp=default handle=27700176
01-27 17:16:22.180: I/dalvikvm(9050): | schedstat=( 6918844000 741848000 1627 ) utm=668 stm=23 core=0
01-27 17:16:22.180: I/dalvikvm(9050): at java.lang.String.<init>(String.java:~432)
01-27 17:16:22.180: I/dalvikvm(9050): at java.io.BufferedReader.readLine(BufferedReader.java:363)
01-27 17:16:22.180: I/dalvikvm(9050): at com.kittykazoo.game.Dictionary.loadWords(Dictionary.java:22)
01-27 17:16:22.180: I/dalvikvm(9050): at com.kittykazoo.gamecore.ScreenLoading.loadAssets(ScreenLoading.java:232)
01-27 17:16:22.180: I/dalvikvm(9050): at com.kittykazoo.gamecore.ScreenLoading.update(ScreenLoading.java:64)
01-27 17:16:22.180: I/dalvikvm(9050): at com.kittykazoo.framework.implementation.AndroidFastRenderView.run(AndroidFastRenderView.java:48)
01-27 17:16:22.180: I/dalvikvm(9050): at java.lang.Thread.run(Thread.java:856)
01-27 17:16:22.280: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:22.280: D/dalvikvm(9050): GC_FOR_ALLOC freed 0K, 1% free 48730K/49159K, paused 107ms
01-27 17:16:22.280: I/dalvikvm-heap(9050): Forcing collection of SoftReferences for 72-byte allocation
01-27 17:16:22.400: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:22.400: D/dalvikvm(9050): GC_BEFORE_OOM freed 0K, 1% free 48730K/49159K, paused 118ms
01-27 17:16:22.400: E/dalvikvm-heap(9050): Out of memory on a 72-byte allocation.
01-27 17:16:22.400: I/dalvikvm(9050): "Thread-1489" prio=5 tid=13 RUNNABLE
01-27 17:16:22.400: I/dalvikvm(9050): | group="main" sCount=0 dsCount=0 obj=0x417e7bd8 self=0x1a6a168
01-27 17:16:22.400: I/dalvikvm(9050): | sysTid=9119 nice=0 sched=0/0 cgrp=default handle=27700176
01-27 17:16:22.400: I/dalvikvm(9050): | schedstat=( 7142111000 746215000 1665 ) utm=690 stm=24 core=0
01-27 17:16:22.400: I/dalvikvm(9050): at java.lang.Throwable.nativeFillInStackTrace(Native Method)
01-27 17:16:22.400: I/dalvikvm(9050): at java.lang.Throwable.fillInStackTrace(Throwable.java:160)
01-27 17:16:22.400: I/dalvikvm(9050): at java.lang.Throwable.<init>(Throwable.java:83)
01-27 17:16:22.400: I/dalvikvm(9050): at java.lang.Error.<init>(Error.java:37)
01-27 17:16:22.400: I/dalvikvm(9050): at java.lang.VirtualMachineError.<init>(VirtualMachineError.java:35)
01-27 17:16:22.400: I/dalvikvm(9050): at java.lang.OutOfMemoryError.<init>(OutOfMemoryError.java:33)
01-27 17:16:22.400: I/dalvikvm(9050): at java.lang.String.<init>(String.java:-1)
01-27 17:16:22.400: I/dalvikvm(9050): at java.io.BufferedReader.readLine(BufferedReader.java:363)
01-27 17:16:22.400: I/dalvikvm(9050): at com.kittykazoo.game.Dictionary.loadWords(Dictionary.java:22)
01-27 17:16:22.400: I/dalvikvm(9050): at com.kittykazoo.gamecore.ScreenLoading.loadAssets(ScreenLoading.java:232)
01-27 17:16:22.400: I/dalvikvm(9050): at com.kittykazoo.gamecore.ScreenLoading.update(ScreenLoading.java:64)
01-27 17:16:22.400: I/dalvikvm(9050): at com.kittykazoo.framework.implementation.AndroidFastRenderView.run(AndroidFastRenderView.java:48)
01-27 17:16:22.400: I/dalvikvm(9050): at java.lang.Thread.run(Thread.java:856)
01-27 17:16:22.410: W/dalvikvm(9050): Exception thrown (Ljava/lang/OutOfMemoryError;) while throwing internal exception (Ljava/lang/OutOfMemoryError;)
01-27 17:16:22.510: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:22.510: D/dalvikvm(9050): GC_FOR_ALLOC freed <1K, 1% free 48730K/49159K, paused 106ms
01-27 17:16:22.510: I/dalvikvm-heap(9050): Forcing collection of SoftReferences for 54-byte allocation
01-27 17:16:22.630: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:22.630: D/dalvikvm(9050): GC_BEFORE_OOM freed 0K, 1% free 48730K/49159K, paused 122ms
01-27 17:16:22.630: E/dalvikvm-heap(9050): Out of memory on a 54-byte allocation.
01-27 17:16:22.630: I/dalvikvm(9050): "Thread-1489" prio=5 tid=13 RUNNABLE
01-27 17:16:22.630: I/dalvikvm(9050): | group="main" sCount=0 dsCount=0 obj=0x417e7bd8 self=0x1a6a168
01-27 17:16:22.630: I/dalvikvm(9050): | sysTid=9119 nice=0 sched=0/0 cgrp=default handle=27700176
01-27 17:16:22.630: I/dalvikvm(9050): | schedstat=( 7366692000 753065000 1725 ) utm=709 stm=27 core=0
01-27 17:16:22.630: I/dalvikvm(9050): at java.io.BufferedReader.readLine(BufferedReader.java:~422)
01-27 17:16:22.630: I/dalvikvm(9050): at com.kittykazoo.game.Dictionary.loadWords(Dictionary.java:22)
01-27 17:16:22.630: I/dalvikvm(9050): at com.kittykazoo.gamecore.ScreenLoading.loadAssets(ScreenLoading.java:232)
01-27 17:16:22.630: I/dalvikvm(9050): at com.kittykazoo.gamecore.ScreenLoading.update(ScreenLoading.java:64)
01-27 17:16:22.630: I/dalvikvm(9050): at com.kittykazoo.framework.implementation.AndroidFastRenderView.run(AndroidFastRenderView.java:48)
01-27 17:16:22.630: I/dalvikvm(9050): at java.lang.Thread.run(Thread.java:856)
01-27 17:16:22.750: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:22.750: D/dalvikvm(9050): GC_FOR_ALLOC freed 0K, 1% free 48730K/49159K, paused 112ms
01-27 17:16:22.750: I/dalvikvm-heap(9050): Forcing collection of SoftReferences for 64-byte allocation
01-27 17:16:22.870: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:22.870: D/dalvikvm(9050): GC_BEFORE_OOM freed 0K, 1% free 48730K/49159K, paused 122ms
01-27 17:16:22.870: E/dalvikvm-heap(9050): Out of memory on a 64-byte allocation.
01-27 17:16:22.870: I/dalvikvm(9050): "Thread-1489" prio=5 tid=13 RUNNABLE
01-27 17:16:22.870: I/dalvikvm(9050): | group="main" sCount=0 dsCount=0 obj=0x417e7bd8 self=0x1a6a168
01-27 17:16:22.870: I/dalvikvm(9050): | sysTid=9119 nice=0 sched=0/0 cgrp=default handle=27700176
01-27 17:16:22.870: I/dalvikvm(9050): | schedstat=( 7590841000 762536000 1798 ) utm=731 stm=28 core=1
01-27 17:16:22.870: I/dalvikvm(9050): at java.lang.Throwable.nativeFillInStackTrace(Native Method)
01-27 17:16:22.870: I/dalvikvm(9050): at java.lang.Throwable.fillInStackTrace(Throwable.java:160)
01-27 17:16:22.870: I/dalvikvm(9050): at java.lang.Throwable.<init>(Throwable.java:83)
01-27 17:16:22.870: I/dalvikvm(9050): at java.lang.Error.<init>(Error.java:37)
01-27 17:16:22.870: I/dalvikvm(9050): at java.lang.VirtualMachineError.<init>(VirtualMachineError.java:35)
01-27 17:16:22.870: I/dalvikvm(9050): at java.lang.OutOfMemoryError.<init>(OutOfMemoryError.java:33)
01-27 17:16:22.870: I/dalvikvm(9050): at java.io.BufferedReader.readLine(BufferedReader.java:-1)
01-27 17:16:22.870: I/dalvikvm(9050): at com.kittykazoo.game.Dictionary.loadWords(Dictionary.java:22)
01-27 17:16:22.870: I/dalvikvm(9050): at com.kittykazoo.gamecore.ScreenLoading.loadAssets(ScreenLoading.java:232)
01-27 17:16:22.870: I/dalvikvm(9050): at com.kittykazoo.gamecore.ScreenLoading.update(ScreenLoading.java:64)
01-27 17:16:22.870: I/dalvikvm(9050): at com.kittykazoo.framework.implementation.AndroidFastRenderView.run(AndroidFastRenderView.java:48)
01-27 17:16:22.870: I/dalvikvm(9050): at java.lang.Thread.run(Thread.java:856)
01-27 17:16:22.870: W/dalvikvm(9050): Exception thrown (Ljava/lang/OutOfMemoryError;) while throwing internal exception (Ljava/lang/OutOfMemoryError;)
01-27 17:16:22.870: W/dalvikvm(9050): Could not resolve class ref'ed in exception catch list (class index 1237, exception Ljava/lang/OutOfMemoryError;)
01-27 17:16:22.870: W/dalvikvm(9050): threadid=13: thread exiting with uncaught exception (group=0x40a391f8)
01-27 17:16:23.000: I/dalvikvm-heap(9050): Clamp target GC heap from 49.620MB to 48.000MB
01-27 17:16:23.000: D/dalvikvm(9050): GC_FOR_ALLOC freed 24K, 1% free 48706K/49159K, paused 128ms
01-27 17:16:23.000: E/AndroidRuntime(9050): FATAL EXCEPTION: Thread-1489
01-27 17:16:23.000: E/AndroidRuntime(9050): java.lang.OutOfMemoryError: [memory exhausted]
01-27 17:16:23.000: E/AndroidRuntime(9050): at dalvik.system.NativeStart.main(Native Method)
01-27 17:18:00.910: I/Process(9050): Sending signal. PID: 9050 SIG: 9
Ended up finding a workaround by using android:largeHeap="true" in the AndroidManifest.xml file.
The AndroidDev documentation says that most applications shouldn't require that, but I don't feel the least bit guilty about it -- if they're going to limit each app to 48mb of RAM with a normal sized heap then I don't see how anyone is supposed to avoid using largeHeap for anything with more than a dozen small bitmaps and some background music.
In my Activity I have the following code:
int picture = Const.a1;
Const.backgroundBitmap = BitmapFactory.decodeResource(getResources(), picture);
Const.backgroundBitmapBonus0 = BitmapFactory.decodeResource(getResources(), Const.bonus_back[0]);
Const.backgroundBitmapBonus1 = BitmapFactory.decodeResource(getResources(), Const.bonus_back[1]);
Const.backgroundBitmapBonus2 = BitmapFactory.decodeResource(getResources(), Const.bonus_back[2]);
Const.backgroundBitmapBonus3 = BitmapFactory.decodeResource(getResources(), Const.bonus_back[3]);
Const.bitmapBackBonus = new Bitmap[4];
Const.bitmapBackBonus[0]= Const.backgroundBitmapBonus0;
Const.bitmapBackBonus[1] = Const.backgroundBitmapBonus1;
Const.bitmapBackBonus[2] = Const.backgroundBitmapBonus2;
Const.bitmapBackBonus[3] = Const.backgroundBitmapBonus3;
And in Const class I have
public static int[] bonus_back = { R.drawable.back_b0 , R.drawable.back_b1 , R.drawable.back_b2 , R.drawable.back_b3};
When I run the app on my device it crashes, while in AVD it worked fine.
How can I use these pictures in right way?
EDIT:
new code using http://developer.android.com/training/displaying-bitmaps/load-bitmap.html
still the same problem
Const.screenWidth = this.getWindowManager().getDefaultDisplay().getWidth();
Const.screenHeight = this.getWindowManager().getDefaultDisplay().getHeight();
int picture = Const.a1;
Const.backgroundBitmapBonus0 = decodeSampledBitmapFromResource(getResources(), Const.bonus_back[0], Const.screenWidth, Const.screenHeight);
Const.backgroundBitmapBonus1 =decodeSampledBitmapFromResource(getResources(), Const.bonus_back[1], Const.screenWidth, Const.screenHeight);
Const.backgroundBitmapBonus2 = decodeSampledBitmapFromResource(getResources(), Const.bonus_back[2], Const.screenWidth, Const.screenHeight);
Const.backgroundBitmapBonus3 = decodeSampledBitmapFromResource(getResources(), Const.bonus_back[3], Const.screenWidth, Const.screenHeight);
Const.backgroundBitmap = decodeSampledBitmapFromResource(getResources(), picture, 100, 100);
/*Const.backgroundBitmap = BitmapFactory.decodeResource(getResources(), picture);
Const.backgroundBitmapBonus0 = BitmapFactory.decodeResource(getResources(), Const.bonus_back[0]);
Const.backgroundBitmapBonus1 = BitmapFactory.decodeResource(getResources(), Const.bonus_back[1]);
Const.backgroundBitmapBonus2 = BitmapFactory.decodeResource(getResources(), Const.bonus_back[2]);
Const.backgroundBitmapBonus3 = BitmapFactory.decodeResource(getResources(), Const.bonus_back[3]);
*/
Const.bitmapBackBonus = new Bitmap[4];
Const.bitmapBackBonus[0]= Const.backgroundBitmapBonus0;
Const.bitmapBackBonus[1] = Const.backgroundBitmapBonus1;
Const.bitmapBackBonus[2] = Const.backgroundBitmapBonus2;
Const.bitmapBackBonus[3] = Const.backgroundBitmapBonus3;
EDIT 2 : Logcat
11-14 09:45:45.525: D/dalvikvm(5623): Late-enabling CheckJNI
11-14 09:45:45.805: D/skia(5623): ---- fAsset->read(3346) returned 0
11-14 09:45:45.905: D/dalvikvm(5623): GC_FOR_ALLOC freed 99K, 3% free 13923K/14343K, paused 37ms
11-14 09:45:45.905: I/dalvikvm-heap(5623): Grow heap (frag case) to 14.807MB for 992016-byte allocation
11-14 09:45:45.945: D/dalvikvm(5623): GC_CONCURRENT freed 1K, 4% free 14890K/15367K, paused 2ms+2ms
11-14 09:45:46.025: D/dalvikvm(5623): GC_FOR_ALLOC freed 0K, 4% free 14890K/15367K, paused 13ms
11-14 09:45:46.075: I/dalvikvm-heap(5623): Grow heap (frag case) to 29.942MB for 15872016-byte allocation
11-14 09:45:46.115: D/dalvikvm(5623): GC_CONCURRENT freed 0K, 2% free 30390K/30919K, paused 2ms+2ms
11-14 09:45:46.515: D/dalvikvm(5623): GC_FOR_ALLOC freed 969K, 5% free 30391K/31943K, paused 18ms
11-14 09:45:46.565: I/dalvikvm-heap(5623): Grow heap (frag case) to 45.080MB for 15872016-byte allocation
11-14 09:45:46.595: D/dalvikvm(5623): GC_CONCURRENT freed <1K, 4% free 45890K/47495K, paused 2ms+3ms
11-14 09:45:46.905: D/dalvikvm(5623): GC_FOR_ALLOC freed 969K, 4% free 45891K/47495K, paused 15ms
11-14 09:45:46.970: I/dalvikvm-heap(5623): Grow heap (frag case) to 60.216MB for 15872016-byte allocation
11-14 09:45:46.990: D/dalvikvm(5623): GC_FOR_ALLOC freed <1K, 3% free 61391K/63047K, paused 18ms
11-14 09:45:47.050: D/dalvikvm(5623): GC_CONCURRENT freed 0K, 3% free 61391K/63047K, paused 2ms+5ms
11-14 09:45:47.345: D/dalvikvm(5623): GC_FOR_ALLOC freed 969K, 3% free 61391K/63047K, paused 14ms
11-14 09:45:47.345: I/dalvikvm-heap(5623): Forcing collection of SoftReferences for 15872016-byte allocation
11-14 09:45:47.390: D/dalvikvm(5623): GC_BEFORE_OOM freed 9K, 3% free 61382K/63047K, paused 32ms
11-14 09:45:47.390: E/dalvikvm-heap(5623): Out of memory on a 15872016-byte allocation.
11-14 09:45:47.390: I/dalvikvm(5623): "main" prio=5 tid=1 RUNNABLE
11-14 09:45:47.390: I/dalvikvm(5623): | group="main" sCount=0 dsCount=0 obj=0x40c6d460 self=0x8a9288
11-14 09:45:47.390: I/dalvikvm(5623): | sysTid=5623 nice=0 sched=0/0 cgrp=default handle=1074558216
11-14 09:45:47.390: I/dalvikvm(5623): | schedstat=( 1288354466 258529951 3812 ) utm=106 stm=22 core=2
11-14 09:45:47.390: I/dalvikvm(5623): at android.graphics.Bitmap.nativeCreate(Native Method)
11-14 09:45:47.390: I/dalvikvm(5623): at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
11-14 09:45:47.390: I/dalvikvm(5623): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
11-14 09:45:47.390: I/dalvikvm(5623): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
11-14 09:45:47.390: I/dalvikvm(5623): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:618)
11-14 09:45:47.390: I/dalvikvm(5623): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:593)
11-14 09:45:47.390: I/dalvikvm(5623): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:445)
11-14 09:45:47.390: I/dalvikvm(5623): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:468)
11-14 09:45:47.390: I/dalvikvm(5623): at com.example.fishe.FullscreenActivity.decodeSampledBitmapFromResource(FullscreenActivity.java:248)
11-14 09:45:47.390: I/dalvikvm(5623): at com.example.fishe.FullscreenActivity.onCreate(FullscreenActivity.java:142)
11-14 09:45:47.390: I/dalvikvm(5623): at android.app.Activity.performCreate(Activity.java:4533)
11-14 09:45:47.395: I/dalvikvm(5623): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
11-14 09:45:47.395: I/dalvikvm(5623): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
11-14 09:45:47.395: I/dalvikvm(5623): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
11-14 09:45:47.395: I/dalvikvm(5623): at android.app.ActivityThread.access$600(ActivityThread.java:128)
11-14 09:45:47.395: I/dalvikvm(5623): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
11-14 09:45:47.395: I/dalvikvm(5623): at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 09:45:47.395: I/dalvikvm(5623): at android.os.Looper.loop(Looper.java:137)
11-14 09:45:47.395: I/dalvikvm(5623): at android.app.ActivityThread.main(ActivityThread.java:4517)
11-14 09:45:47.395: I/dalvikvm(5623): at java.lang.reflect.Method.invokeNative(Native Method)
11-14 09:45:47.395: I/dalvikvm(5623): at java.lang.reflect.Method.invoke(Method.java:511)
11-14 09:45:47.395: I/dalvikvm(5623): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
11-14 09:45:47.395: I/dalvikvm(5623): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
11-14 09:45:47.395: I/dalvikvm(5623): at dalvik.system.NativeStart.main(Native Method)
11-14 09:45:47.395: D/AndroidRuntime(5623): Shutting down VM
11-14 09:45:47.395: W/dalvikvm(5623): threadid=1: thread exiting with uncaught exception (group=0x40c6c1f8)
11-14 09:45:47.395: E/AndroidRuntime(5623): FATAL EXCEPTION: main
11-14 09:45:47.395: E/AndroidRuntime(5623): java.lang.OutOfMemoryError
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.graphics.Bitmap.nativeCreate(Native Method)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:618)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:593)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:445)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:468)
11-14 09:45:47.395: E/AndroidRuntime(5623): at com.example.fishe.FullscreenActivity.decodeSampledBitmapFromResource(FullscreenActivity.java:248)
11-14 09:45:47.395: E/AndroidRuntime(5623): at com.example.fishe.FullscreenActivity.onCreate(FullscreenActivity.java:142)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.app.Activity.performCreate(Activity.java:4533)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.app.ActivityThread.access$600(ActivityThread.java:128)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.os.Looper.loop(Looper.java:137)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.app.ActivityThread.main(ActivityThread.java:4517)
11-14 09:45:47.395: E/AndroidRuntime(5623): at java.lang.reflect.Method.invokeNative(Native Method)
11-14 09:45:47.395: E/AndroidRuntime(5623): at java.lang.reflect.Method.invoke(Method.java:511)
11-14 09:45:47.395: E/AndroidRuntime(5623): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
11-14 09:45:47.395: E/AndroidRuntime(5623): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
11-14 09:45:47.395: E/AndroidRuntime(5623): at dalvik.system.NativeStart.main(Native Method)
11-14 09:45:56.490: I/Process(5623): Sending signal. PID: 5623 SIG: 9
If the image is too big you're probably running out of memory.
Check http://developer.android.com/training/displaying-bitmaps/load-bitmap.html to learn how to load a scaled-down version of the image.
I'm writing an Android app. It has two pages. The second page is supposed to be a page full of image buttons. But when I run my app in the emulator and go to the second page, the page is not displayed. Why?
Here's an error I get:
Android logcat Text :Fatal signal 11(SIGSEGV) at 0X00000000 (code==1) ,thread 614(com.s
THIS IS THE ENTIRE LOGCAT
: D/gralloc_goldfish(614): Emulator without GPU emulation detected.
01-14 09:08:14.554: D/dalvikvm(614): GC_FOR_ALLOC freed 89K, 3% free 8141K/8327K, paused 33ms, total 35ms
01-14 09:08:14.584: I/dalvikvm-heap(614): Grow heap (frag case) to 10.998MB for 3145744-byte allocation
01-14 09:08:14.744: D/dalvikvm(614): GC_CONCURRENT freed 4K, 3% free 11209K/11463K, paused 105ms+15ms, total 160ms
01-14 09:08:15.054: D/dalvikvm(614): GC_FOR_ALLOC freed 0K, 3% free 11209K/11463K, paused 22ms, total 22ms
01-14 09:08:15.104: I/dalvikvm-heap(614): Grow heap (frag case) to 17.744MB for 7077904-byte allocation
01-14 09:08:15.254: D/dalvikvm(614): GC_CONCURRENT freed 0K, 2% free 18121K/18439K, paused 97ms+6ms, total 157ms
01-14 09:08:15.424: D/dalvikvm(614): GC_FOR_ALLOC freed 3072K, 19% free 15050K/18439K, paused 27ms, total 27ms
01-14 09:08:15.424: I/dalvikvm-heap(614): Grow heap (frag case) to 17.745MB for 3145744-byte allocation
01-14 09:08:15.574: D/dalvikvm(614): GC_CONCURRENT freed <1K, 2% free 18122K/18439K, paused 102ms+15ms, total 149ms
01-14 09:08:15.904: D/dalvikvm(614): GC_FOR_ALLOC freed 0K, 2% free 18122K/18439K, paused 27ms, total 27ms
01-14 09:08:15.954: I/dalvikvm-heap(614): Grow heap (frag case) to 24.495MB for 7077904-byte allocation
01-14 09:08:16.094: D/dalvikvm(614): GC_CONCURRENT freed 0K, 2% free 25034K/25415K, paused 76ms+6ms, total 140ms
01-14 09:08:16.304: D/dalvikvm(614): GC_FOR_ALLOC freed 3072K, 14% free 21964K/25415K, paused 32ms, total 33ms
01-14 09:08:16.314: I/dalvikvm-heap(614): Grow heap (frag case) to 24.498MB for 3145744-byte allocation
01-14 09:08:16.484: D/dalvikvm(614): GC_CONCURRENT freed <1K, 2% free 25036K/25415K, paused 109ms+16ms, total 170ms
01-14 09:08:16.764: D/dalvikvm(614): GC_FOR_ALLOC freed 0K, 2% free 25036K/25415K, paused 30ms, total 30ms
01-14 09:08:16.814: I/dalvikvm-heap(614): Grow heap (frag case) to 31.248MB for 7077904-byte allocation
01-14 09:08:16.994: D/dalvikvm(614): GC_CONCURRENT freed 0K, 2% free 31948K/32391K, paused 99ms+7ms, total 180ms
01-14 09:08:17.145: D/dalvikvm(614): GC_FOR_ALLOC freed 3072K, 11% free 28878K/32391K, paused 37ms, total 37ms
01-14 09:08:17.154: I/dalvikvm-heap(614): Grow heap (frag case) to 31.249MB for 3145744-byte allocation
01-14 09:08:17.314: D/dalvikvm(614): GC_CONCURRENT freed <1K, 2% free 31950K/32391K, paused 82ms+18ms, total 161ms
01-14 09:08:17.624: D/dalvikvm(614): GC_FOR_ALLOC freed 0K, 2% free 31950K/32391K, paused 41ms, total 41ms
01-14 09:08:17.674: I/dalvikvm-heap(614): Grow heap (frag case) to 37.999MB for 7077904-byte allocation
01-14 09:08:17.874: D/dalvikvm(614): GC_CONCURRENT freed 0K, 2% free 38862K/39367K, paused 108ms+8ms, total 204ms
01-14 09:08:18.024: D/dalvikvm(614): GC_FOR_ALLOC freed 3072K, 10% free 35791K/39367K, paused 41ms, total 42ms
01-14 09:08:18.024: I/dalvikvm-heap(614): Grow heap (frag case) to 38.000MB for 3145744-byte allocation
01-14 09:08:18.184: D/dalvikvm(614): GC_CONCURRENT freed <1K, 2% free 38863K/39367K, paused 73ms+20ms, total 157ms
01-14 09:08:18.514: D/dalvikvm(614): GC_FOR_ALLOC freed 0K, 2% free 38863K/39367K, paused 40ms, total 40ms
01-14 09:08:18.564: I/dalvikvm-heap(614): Grow heap (frag case) to 44.750MB for 7077904-byte allocation
01-14 09:08:18.794: D/dalvikvm(614): GC_CONCURRENT freed 0K, 2% free 45775K/46343K, paused 92ms+21ms, total 228ms
01-14 09:08:18.954: D/dalvikvm(614): GC_FOR_ALLOC freed 3072K, 8% free 42704K/46343K, paused 43ms, total 44ms
01-14 09:08:18.954: I/dalvikvm-heap(614): Grow heap (frag case) to 44.751MB for 3145744-byte allocation
01-14 09:08:19.114: D/dalvikvm(614): GC_CONCURRENT freed <1K, 2% free 45776K/46343K, paused 74ms+7ms, total 162ms
01-14 09:08:19.445: D/dalvikvm(614): GC_FOR_ALLOC freed 0K, 2% free 45776K/46343K, paused 60ms, total 60ms
01-14 09:08:19.445: I/dalvikvm-heap(614): Forcing collection of SoftReferences for 7077904-byte allocation
01-14 09:08:19.875: D/dalvikvm(614): GC_BEFORE_OOM freed 9K, 2% free 45767K/46343K, paused 426ms, total 427ms
01-14 09:08:19.875: E/dalvikvm-heap(614): Out of memory on a 7077904-byte allocation.
01-14 09:08:19.875: I/dalvikvm(614): "main" prio=5 tid=1 RUNNABLE
01-14 09:08:19.875: I/dalvikvm(614): | group="main" sCount=0 dsCount=0 obj=0x40a14568 self=0x2a00b9e0
01-14 09:08:19.875: I/dalvikvm(614): | sysTid=614 nice=0 sched=0/0 cgrp=apps handle=1073870640
01-14 09:08:19.885: I/dalvikvm(614): | schedstat=( 3996873888 1969503221 492 ) utm=351 stm=48 core=0
01-14 09:08:19.885: I/dalvikvm(614): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
01-14 09:08:19.885: I/dalvikvm(614): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:500)
01-14 09:08:19.885: I/dalvikvm(614): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:353)
01-14 09:08:19.885: I/dalvikvm(614): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
01-14 09:08:19.885: I/dalvikvm(614): at android.content.res.Resources.loadDrawable(Resources.java:1930)
01-14 09:08:19.885: I/dalvikvm(614): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
01-14 09:08:19.894: I/dalvikvm(614): at android.widget.ImageView.<init>(ImageView.java:120)
01-14 09:08:19.894: I/dalvikvm(614): at android.widget.ImageView.<init>(ImageView.java:110)
01-14 09:08:19.904: I/dalvikvm(614): at java.lang.reflect.Constructor.constructNative(Native Method)
01-14 09:08:19.904: I/dalvikvm(614): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
01-14 09:08:19.904: I/dalvikvm(614): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
01-14 09:08:19.904: I/dalvikvm(614): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
01-14 09:08:19.904: I/dalvikvm(614): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
01-14 09:08:19.904: I/dalvikvm(614): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
01-14 09:08:19.904: I/dalvikvm(614): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
01-14 09:08:19.904: I/dalvikvm(614): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
01-14 09:08:19.904: I/dalvikvm(614): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
01-14 09:08:19.904: I/dalvikvm(614): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
01-14 09:08:19.904: I/dalvikvm(614): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
01-14 09:08:19.904: I/dalvikvm(614): at android.app.Activity.setContentView(Activity.java:1867)
01-14 09:08:19.904: I/dalvikvm(614): at com.sgs.First.onCreate(First.java:13)
01-14 09:08:19.904: I/dalvikvm(614): at android.app.Activity.performCreate(Activity.java:5008)
01-14 09:08:19.904: I/dalvikvm(614): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
01-14 09:08:19.904: I/dalvikvm(614): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
01-14 09:08:19.904: I/dalvikvm(614): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
01-14 09:08:19.904: I/dalvikvm(614): at android.app.ActivityThread.access$600(ActivityThread.java:130)
01-14 09:08:19.904: I/dalvikvm(614): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
01-14 09:08:19.904: I/dalvikvm(614): at android.os.Handler.dispatchMessage(Handler.java:99)
01-14 09:08:19.904: I/dalvikvm(614): at android.os.Looper.loop(Looper.java:137)
01-14 09:08:19.904: I/dalvikvm(614): at android.app.ActivityThread.main(ActivityThread.java:4745)
01-14 09:08:19.904: I/dalvikvm(614): at java.lang.reflect.Method.invokeNative(Native Method)
01-14 09:08:19.904: I/dalvikvm(614): at java.lang.reflect.Method.invoke(Method.java:511)
01-14 09:08:19.904: I/dalvikvm(614): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
01-14 09:08:19.914: I/dalvikvm(614): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
01-14 09:08:19.914: I/dalvikvm(614): at dalvik.system.NativeStart.main(Native Method)
01-14 09:08:19.930: A/libc(614): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 614 (com.sgs)
THIS IS THE XML CODE
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageButton1"
android:layout_width="160dp"
android:layout_height="100dp"
android:src="#drawable/c" />
<ImageView
android:id="#+id/imageButton2"
android:layout_width="160dp"
android:layout_height="100dp"
android:src="#drawable/d" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="300dp"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageButton3"
android:layout_width="80dp"
android:layout_height="300dp"
android:src="#drawable/e" />
<ImageView
android:id="#+id/imageButton4"
android:layout_width="160dp"
android:layout_height="300dp"
android:src="#drawable/g" />
<ImageView
android:id="#+id/imageButton5"
android:layout_width="80dp"
android:layout_height="300dp"
android:src="#drawable/f" />
</LinearLayout>
<ImageView
android:id="#+id/imageButton6"
android:layout_width="320dp"
android:layout_height="100dp"
android:src="#drawable/h" />
</LinearLayout>
THIS IS THE CORRESPONDING JAVA FILE
package com.sgs;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
public class First extends Activity implements OnClickListener {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.first);
ImageView image1 = (ImageView) findViewById(R.id.imageButton1);
ImageView image2 = (ImageView) findViewById(R.id.imageButton2);
ImageView image3 = (ImageView) findViewById(R.id.imageButton3);
ImageView image4 = (ImageView) findViewById(R.id.imageButton4);
ImageView image5 = (ImageView) findViewById(R.id.imageButton5);
image1.setOnClickListener(this);
image2.setOnClickListener(this);
image3.setOnClickListener(this);
image4.setOnClickListener(this);
image5.setOnClickListener(this);
}
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()){
case R.id.imageButton1:
}
}
}
From the log you can see an out of memory error when an image is beeing decoded:
01-14 09:08:19.875: E/dalvikvm-heap(614): Out of memory on a 7077904-byte allocation.
Maybe the images used (by mistake) are to large for the memory allocated by you emulator device profile. You could try increasing the heap size of the device (Window-->AVD Manager-->Virtual Devices-->Edit : Hardware properties)
here is my error log please help?
I am a newbie to android and this is my first app
package gaurav.rapp.swamiji;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageSwitcher;
import android.widget.ImageView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ViewSwitcher.ViewFactory;
public class BeWithSwamijiActivity extends Activity implements ViewFactory {
Integer pics[]={R.drawable.img1,R.drawable.img2,R.drawable.img3,R.drawable.img4,R.drawable.img5,R.drawable.img6,R.drawable.img7,R.drawable.img8,R.drawable.img9,R.drawable.img10,R.drawable.img11,R.drawable.img12,R.drawable.img13,R.drawable.img14,R.drawable.img15,R.drawable.img16,R.drawable.img17};
ImageSwitcher iSwitcher;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
iSwitcher = (ImageSwitcher) findViewById(R.id.ImageSwitcher01);
iSwitcher.setFactory(this);
iSwitcher.setInAnimation(AnimationUtils.loadAnimation(this,
android.R.anim.fade_in));
iSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this,
android.R.anim.fade_out));
Gallery gallery = (Gallery) findViewById(R.id.Gallery01);
gallery.setAdapter(new ImageAdapter(this));
gallery.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
iSwitcher.setImageResource(pics[arg2]);
}
});
}
public class ImageAdapter extends BaseAdapter {
private Context ctx;
public ImageAdapter(Context c) {
ctx = c;
}
#Override
public int getCount() {
return pics.length;
}
#Override
public Object getItem(int arg0) {
return arg0;
}
#Override
public long getItemId(int arg0) {
return arg0;
}
#Override
public View getView(int arg0, View arg1, ViewGroup arg2) {
ImageView iView = new ImageView(ctx);
iView.setImageResource(pics[arg0]);
iView.setScaleType(ImageView.ScaleType.FIT_XY);
iView.setLayoutParams(new Gallery.LayoutParams(150, 150));
return iView;
}
}
#Override
public View makeView() {
ImageView iView=new ImageView(this);
iView.setScaleType(ImageView.ScaleType.FIT_CENTER);
iView.setLayoutParams(new ImageSwitcher.LayoutParams(
LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
iView.setBackgroundColor(0xFF000000);
return iView;
}
}
Log
05-13 21:58:39.107: I/Process(397): Sending signal. PID: 397 SIG: 9
05-13 21:58:45.517: D/dalvikvm(409): GC_FOR_ALLOC freed 43K, 4% free 6362K/6595K, paused 75ms
05-13 21:58:45.587: I/dalvikvm-heap(409): Grow heap (frag case) to 10.624MB for 4566704-byte allocation
05-13 21:58:45.697: D/dalvikvm(409): GC_FOR_ALLOC freed 1K, 3% free 10820K/11079K, paused 86ms
05-13 21:58:45.887: D/dalvikvm(409): GC_CONCURRENT freed <1K, 3% free 10820K/11079K, paused 25ms+3ms
05-13 21:58:46.427: D/dalvikvm(409): GC_FOR_ALLOC freed <1K, 3% free 10820K/11079K, paused 112ms
05-13 21:58:46.547: I/dalvikvm-heap(409): Grow heap (frag case) to 18.362MB for 8114772-byte allocation
05-13 21:58:46.839: D/dalvikvm(409): GC_FOR_ALLOC freed 0K, 2% free 18745K/19015K, paused 72ms
05-13 21:58:47.057: D/dalvikvm(409): GC_CONCURRENT freed 0K, 2% free 18745K/19015K, paused 4ms+16ms
05-13 21:58:47.680: D/dalvikvm(409): GC_FOR_ALLOC freed 5051K, 26% free 15340K/20679K, paused 72ms
05-13 21:58:47.889: D/dalvikvm(409): GC_FOR_ALLOC freed <1K, 21% free 16537K/20679K, paused 71ms
05-13 21:58:47.889: I/dalvikvm-heap(409): Grow heap (frag case) to 18.284MB for 2179600-byte allocation
05-13 21:58:48.037: D/dalvikvm(409): GC_FOR_ALLOC freed 0K, 10% free 18666K/20679K, paused 75ms
05-13 21:58:48.307: D/dalvikvm(409): GC_CONCURRENT freed 0K, 10% free 18666K/20679K, paused 5ms+3ms
05-13 21:58:48.511: D/dalvikvm(409): GC_FOR_ALLOC freed 1197K, 11% free 18425K/20679K, paused 73ms
05-13 21:58:48.530: I/dalvikvm-heap(409): Grow heap (frag case) to 19.705MB for 1735988-byte allocation
05-13 21:58:48.681: D/dalvikvm(409): GC_FOR_ALLOC freed 0K, 11% free 20120K/22407K, paused 76ms
05-13 21:59:09.187: D/dalvikvm(409): GC_FOR_ALLOC freed 961K, 13% free 19660K/22407K, paused 75ms
05-13 21:59:11.737: D/dalvikvm(409): GC_FOR_ALLOC freed 678K, 10% free 20385K/22407K, paused 143ms
05-13 21:59:11.797: I/dalvikvm-heap(409): Grow heap (frag case) to 24.518MB for 4776976-byte allocation
05-13 21:59:11.971: D/dalvikvm(409): GC_FOR_ALLOC freed <1K, 8% free 25049K/27079K, paused 85ms
05-13 21:59:12.117: D/dalvikvm(409): GC_CONCURRENT freed <1K, 8% free 25049K/27079K, paused 4ms+3ms
05-13 21:59:12.327: D/dalvikvm(409): GC_FOR_ALLOC freed <1K, 8% free 25049K/27079K, paused 93ms
05-13 21:59:12.437: I/dalvikvm-heap(409): Grow heap (frag case) to 32.619MB for 8494048-byte allocation
05-13 21:59:12.589: D/dalvikvm(409): GC_FOR_ALLOC freed 0K, 6% free 33344K/35399K, paused 82ms
05-13 21:59:12.877: D/dalvikvm(409): GC_CONCURRENT freed 0K, 6% free 33345K/35399K, paused 5ms+4ms
05-13 21:59:29.208: D/dalvikvm(409): GC_FOR_ALLOC freed 4862K, 17% free 29383K/35399K, paused 84ms
05-13 21:59:31.130: D/dalvikvm(409): GC_FOR_ALLOC freed 353K, 13% free 30855K/35399K, paused 84ms
05-13 21:59:31.137: I/dalvikvm-heap(409): Grow heap (frag case) to 32.266MB for 2179600-byte allocation
05-13 21:59:31.287: D/dalvikvm(409): GC_FOR_ALLOC freed <1K, 7% free 32983K/35399K, paused 82ms
05-13 21:59:31.538: D/dalvikvm(409): GC_CONCURRENT freed 0K, 7% free 32983K/35399K, paused 5ms+4ms
05-13 21:59:31.647: D/dalvikvm(409): GC_FOR_ALLOC freed 1549K, 12% free 31435K/35399K, paused 92ms
05-13 21:59:31.692: I/dalvikvm-heap(409): Grow heap (frag case) to 33.028MB for 2384216-byte allocation
05-13 21:59:31.880: D/dalvikvm(409): GC_FOR_ALLOC freed 0K, 11% free 33764K/37767K, paused 100ms
05-13 21:59:32.057: D/dalvikvm(409): GC_CONCURRENT freed <1K, 11% free 33764K/37767K, paused 4ms+4ms
05-13 21:59:32.307: D/dalvikvm(409): GC_FOR_ALLOC freed <1K, 11% free 33764K/37767K, paused 108ms
05-13 21:59:32.377: I/dalvikvm-heap(409): Grow heap (frag case) to 37.073MB for 4241380-byte allocation
05-13 21:59:32.547: D/dalvikvm(409): GC_FOR_ALLOC freed 0K, 10% free 37906K/41927K, paused 97ms
05-13 21:59:32.797: D/dalvikvm(409): GC_CONCURRENT freed 0K, 10% free 37906K/41927K, paused 4ms+14ms
05-13 21:59:34.747: D/dalvikvm(409): GC_FOR_ALLOC freed 2329K, 13% free 36533K/41927K, paused 98ms
05-13 21:59:35.037: D/dalvikvm(409): GC_CONCURRENT freed 1304K, 12% free 37261K/41927K, paused 4ms+4ms
05-13 21:59:42.547: D/dalvikvm(409): GC_FOR_ALLOC freed 337K, 11% free 37524K/41927K, paused 88ms
05-13 21:59:42.607: I/dalvikvm-heap(409): Grow heap (frag case) to 41.255MB for 4776976-byte allocation
05-13 21:59:42.801: D/dalvikvm(409): GC_FOR_ALLOC freed <1K, 10% free 42188K/46599K, paused 104ms
05-13 21:59:43.021: D/dalvikvm(409): GC_CONCURRENT freed <1K, 10% free 42188K/46599K, paused 4ms+4ms
05-13 21:59:43.180: D/dalvikvm(409): GC_FOR_ALLOC freed <1K, 10% free 42189K/46599K, paused 98ms
05-13 21:59:43.180: I/dalvikvm-heap(409): Forcing collection of SoftReferences for 8494048-byte allocation
05-13 21:59:43.327: D/dalvikvm(409): GC_BEFORE_OOM freed 8K, 10% free 42180K/46599K, paused 143ms
05-13 21:59:43.327: E/dalvikvm-heap(409): Out of memory on a 8494048-byte allocation.
05-13 21:59:43.337: I/dalvikvm(409): "main" prio=5 tid=1 RUNNABLE
05-13 21:59:43.337: I/dalvikvm(409): | group="main" sCount=0 dsCount=0 obj=0x4001b5c8 self=0x125d8
05-13 21:59:43.337: I/dalvikvm(409): | sysTid=409 nice=0 sched=0/0 cgrp=default handle=-1342913432
05-13 21:59:43.337: I/dalvikvm(409): | schedstat=( 10690152881 5424008534 597 ) utm=864 stm=205 core=0
05-13 21:59:43.337: I/dalvikvm(409): at android.graphics.Bitmap.nativeCreate(Native Method)
05-13 21:59:43.337: I/dalvikvm(409): at android.graphics.Bitmap.createBitmap(Bitmap.java:604)
05-13 21:59:43.337: I/dalvikvm(409): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
05-13 21:59:43.337: I/dalvikvm(409): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
05-13 21:59:43.337: I/dalvikvm(409): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:524)
05-13 21:59:43.347: I/dalvikvm(409): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:499)
05-13 21:59:43.347: I/dalvikvm(409): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
05-13 21:59:43.347: I/dalvikvm(409): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:738)
05-13 21:59:43.347: I/dalvikvm(409): at android.content.res.Resources.loadDrawable(Resources.java:1918)
05-13 21:59:43.347: I/dalvikvm(409): at android.content.res.Resources.getDrawable(Resources.java:655)
05-13 21:59:43.357: I/dalvikvm(409): at android.widget.ImageView.resolveUri(ImageView.java:510)
05-13 21:59:43.357: I/dalvikvm(409): at android.widget.ImageView.setImageResource(ImageView.java:289)
05-13 21:59:43.357: I/dalvikvm(409): at android.widget.ImageSwitcher.setImageResource(ImageSwitcher.java:41)
05-13 21:59:43.357: I/dalvikvm(409): at gaurav.rapp.swamiji.BeWithSwamijiActivity$1.onItemClick(BeWithSwamijiActivity.java:39)
05-13 21:59:43.357: I/dalvikvm(409): at android.widget.AdapterView.performItemClick(AdapterView.java:282)
05-13 21:59:43.357: I/dalvikvm(409): at android.widget.Gallery.onSingleTapUp(Gallery.java:867)
05-13 21:59:43.357: I/dalvikvm(409): at android.view.GestureDetector.onTouchEvent(GestureDetector.java:557)
05-13 21:59:43.357: I/dalvikvm(409): at android.widget.Gallery.onTouchEvent(Gallery.java:842)
05-13 21:59:43.377: I/dalvikvm(409): at android.view.View.dispatchTouchEvent(View.java:4609)
05-13 21:59:43.377: I/dalvikvm(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1554)
05-13 21:59:43.377: I/dalvikvm(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1320)
05-13 21:59:43.377: I/dalvikvm(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
05-13 21:59:43.387: I/dalvikvm(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
05-13 21:59:43.387: I/dalvikvm(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
05-13 21:59:43.387: I/dalvikvm(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
05-13 21:59:43.387: I/dalvikvm(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
05-13 21:59:43.387: I/dalvikvm(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
05-13 21:59:43.387: I/dalvikvm(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
05-13 21:59:43.387: I/dalvikvm(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
05-13 21:59:43.387: I/dalvikvm(409): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1709)
05-13 21:59:43.407: I/dalvikvm(409): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1264)
05-13 21:59:43.407: I/dalvikvm(409): at android.app.Activity.dispatchTouchEvent(Activity.java:2315)
05-13 21:59:43.407: I/dalvikvm(409): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1682)
05-13 21:59:43.417: I/dalvikvm(409): at android.view.View.dispatchPointerEvent(View.java:4677)
05-13 21:59:43.417: I/dalvikvm(409): at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2392)
05-13 21:59:43.417: I/dalvikvm(409): at android.view.ViewRoot.handleMessage(ViewRoot.java:2054)
05-13 21:59:43.417: I/dalvikvm(409): at android.os.Handler.dispatchMessage(Handler.java:99)
05-13 21:59:43.417: I/dalvikvm(409): at android.os.Looper.loop(Looper.java:132)
05-13 21:59:43.417: I/dalvikvm(409): at android.app.ActivityThread.main(ActivityThread.java:4123)
05-13 21:59:43.417: I/dalvikvm(409): at java.lang.reflect.Method.invokeNative(Native Method)
05-13 21:59:43.417: I/dalvikvm(409): at java.lang.reflect.Method.invoke(Method.java:491)
05-13 21:59:43.417: I/dalvikvm(409): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
05-13 21:59:43.417: I/dalvikvm(409): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
05-13 21:59:43.417: I/dalvikvm(409): at dalvik.system.NativeStart.main(Native Method)
05-13 21:59:43.417: D/AndroidRuntime(409): Shutting down VM
05-13 21:59:43.417: W/dalvikvm(409): threadid=1: thread exiting with uncaught exception (group=0x40014760)
05-13 21:59:43.467: E/AndroidRuntime(409): FATAL EXCEPTION: main
05-13 21:59:43.467: E/AndroidRuntime(409): java.lang.OutOfMemoryError
05-13 21:59:43.467: E/AndroidRuntime(409): at android.graphics.Bitmap.nativeCreate(Native Method)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.graphics.Bitmap.createBitmap(Bitmap.java:604)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:524)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:499)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:738)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.content.res.Resources.loadDrawable(Resources.java:1918)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.content.res.Resources.getDrawable(Resources.java:655)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.widget.ImageView.resolveUri(ImageView.java:510)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.widget.ImageView.setImageResource(ImageView.java:289)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.widget.ImageSwitcher.setImageResource(ImageSwitcher.java:41)
05-13 21:59:43.467: E/AndroidRuntime(409): at gaurav.rapp.swamiji.BeWithSwamijiActivity$1.onItemClick(BeWithSwamijiActivity.java:39)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.widget.AdapterView.performItemClick(AdapterView.java:282)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.widget.Gallery.onSingleTapUp(Gallery.java:867)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.GestureDetector.onTouchEvent(GestureDetector.java:557)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.widget.Gallery.onTouchEvent(Gallery.java:842)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.View.dispatchTouchEvent(View.java:4609)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1554)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1320)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
05-13 21:59:43.467: E/AndroidRuntime(409): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1709)
05-13 21:59:43.467: E/AndroidRuntime(409): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1264)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.app.Activity.dispatchTouchEvent(Activity.java:2315)
05-13 21:59:43.467: E/AndroidRuntime(409): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1682)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.View.dispatchPointerEvent(View.java:4677)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2392)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewRoot.handleMessage(ViewRoot.java:2054)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.os.Handler.dispatchMessage(Handler.java:99)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.os.Looper.loop(Looper.java:132)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.app.ActivityThread.main(ActivityThread.java:4123)
05-13 21:59:43.467: E/AndroidRuntime(409): at java.lang.reflect.Method.invokeNative(Native Method)
05-13 21:59:43.467: E/AndroidRuntime(409): at java.lang.reflect.Method.invoke(Method.java:491)
05-13 21:59:43.467: E/AndroidRuntime(409): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
05-13 21:59:43.467: E/AndroidRuntime(409): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
05-13 21:59:43.467: E/AndroidRuntime(409): at dalvik.system.NativeStart.main(Native Method)
05-13 21:59:46.117: I/Process(409): Sending signal. PID: 409 SIG: 9
Out of memory on a 8494048-byte allocation.
Don't try to load 8MB bitmaps! Resize your assets to something more appropriate, or look at BitmapFactory.Options to downscale whatever it is you are trying to load.