Skip to main content

Posts

Showing posts with the label heap

Detect application heap size in Android

How do you programmatically detect the application heap size available to an Android app? I heard there's a function that does this in later versions of the SDK. In any case, I'm looking for solution that works for 1.5 and upwards. Source: Tips4all

Android Activity causing Service crash due to heap fragmentation

I have an Android app (activity) which also has a corresponding service. The service is started by the activity and is supposed to run continuously even when the activity is stopped. When the activity is started again it can bind to the service and query it. Sometimes the activity gets destroyed and created by the OS. This should not affect things, the activity should just be re-created and be able to bind to the service again. This basically works. However... I have found that both the Dalvik VM heap and the native heap are non-compacting and therefore constantly increase in size until the activity runs out of memory and crashes (even though the total memory usage is actually constant and not leaking). This is much exacerbated by destroying and re-creating the activity since a lot of allocations are done during the creation process. This pretty much guarentees that the activity will crash after a number of restarts. This doesn't bother me that much, but what then happens

DiskStore .throwableSafeExpireElementsIfRequired(620) org.appfuse.model.User Cache: Could not expire elements from disk due to null

I am facing above exception followed by OutOfMemoryException. JVMDUMP013I Processed Dump Event "systhrow", detail "java/lang/OutOfMemoryError". ERROR [Store org.appfuse.model.User Spool Thread] DiskStore.throwableSafeExpireElementsIfRequired(620) | org.appfuse.model.User Cache: Could not expire elements from disk due to null. Continuing... java.lang.OutOfMemoryError at java.util.Collections$SynchronizedMap . values (Unknown Source) at net.sf.ehcache.store.DiskStore . expireElements at net.sf.ehcache.store. DiskStore . Exception in thread "QuartzScheduler_QuartzSchedulerThread" java.lang.OutOfMemoryError at java.lang.String.<init>(String.java:364) at org.quartz.Trigger.getFullName(Trigger.java:435) at org.quartz.simpl.TriggerComparator.compare(RAMJobStore.java:1408) at java.util.TreeMap.find(Unknown Source) at java.util.TreeMap.remove(Unknown Source) at java.util.TreeSet.remove(Unknown