Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

Whats the Excellent way to solve the memory leak problem in android app?

Memory management in android app

user-image
Question added by Mohammad Faiz Alam , Engineering Lead , Persistent Systems Limited
Date Posted: 2017/06/12
Mohd Faisal
by Mohd Faisal , Senior Mobile Application Developer(Android/iOS/Flutter) , Naqel Express

A memory leaks occur in java when you forget to close resource ,or a reference to an object is not released. e.g.

a.File/Text buffer are not closed. 

b.Inner classes that references outer classes.

 

How to fix it.....

There are two ways to fix it one is 'qucik attempt' if first fail then second one is long way to fix it.

1.Eclipse memory leak warning(how to use check it on internet)

2.Manually disable and enable parts of your code and observe memory usage of your JVM using a JVM Tool Like 'VISUALJVM'(Check it on internet how to use it)

Mohammad Faiz  Alam
by Mohammad Faiz Alam , Engineering Lead , Persistent Systems Limited

By using RxJava implementation.  RxJava is the open-source implementation of ReactiveX in Java. The two main classes are Observable and Subscriber. In RxJava, an Observable is a class that emits a stream of data or events, and a Subscriber is a class that acts upon the emitted items.

Simple Threading in Android

A common scenario in Android development is the need to offload some amount of work to a background thread, and once that task has finished, post the results on the main thread in order to display the results. With Android, we are given multiple options to do something like this natively, using AsyncTasks, Loaders, Services, etc. However, these solutions are often not the best. Asynctasks can easily lead to memory leaks, CursorLoaders with a ContentProvider require a large amount of configuration and boilerplate code to setup, and Services are intended for longer running background tasks and not fast-finishing operations such as making a network call or loading content from a database. Let’s see how RxJava can help solve these problems. Given the following Layout that has a button to start a long running operation, and an always displayed progress circle so that we can make sure that our operation is being run on a background thread, and not on the main UI thread.

 

More Questions Like This