Tag Archives: Runtime

Do we need to call the Garbage Collector manually ( System.gc() ) in Android?

By | September 5, 2017

This is a common question. Eventhough the Android System calls garabage collector at appropriate times, this usually will not be adequate. Because the system calls GC at intervals, most of the time it wont work perfect and causing unnecessary pauses in the application. If these pauses are more than 16ms, then the user will notice some lag in… Read More »

Faster Loading images in GridViews or ListViews in Android using Menory Caching, Complete implemenation with sample code.

By | September 1, 2013

Hi all This example shows you how to load large images in the gridview without any lag or without outofmemory error. This sample application uses the LruCache to hold the images. A cache that holds strong references to a limited number of values. Each time a value is accessed, it is moved to the head of a queue.… Read More »

What is a Memory Heap Size in android? and how can use Bitmap Efficiently?

By | August 25, 2013

Memory Heap Size Android is a full multitasking system so it’s possible to run multiple programs at the same time and obviously each one can’t use all of your device memory. For this reason there is a hard limit on your Android application’s heap size: if your application needs to allocate more memory and you have gone up… Read More »

How to explicitly free memory in android OR Release unwanted memory in Android?

By | April 24, 2012

If you are writing memory consuming applications there is a bigger chance that your application may be running out of memory after sometime. So there are some methods in android that invokes the garbage collector explicitly. See the following function which invokes the garbage collector to free a lot of memory. [java] public void freeMemory(){ System.runFinalization(); Runtime.getRuntime().gc(); System.gc();… Read More »

How to read Logcat contents programmatically in Android?

By | July 16, 2011

This is an example to read Logcat contents programmatically in Android. Normal developers won’t need this, but still it is a good thing to know how to do it. [java] package pack.coderzheaven; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class ReadLogDemo extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);… Read More »