Register now or log in to join your professional community.
Memory management in android app
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)
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.