News for hackers. Stuff that matters.
Re:A Closer Look at Android RunTime in Android L by on_and_off on Monday November 10, 2014 @03:55AM (#8582588)
If animations lag because of allocations, then you are allocating too many objects.. The most common cause is object allocation in a critical part like a draw call (or view binding).
Re:A Closer Look at Android RunTime in Android L by rohan404 on Monday November 10, 2014 @04:02AM (#8582613)
This is true, but for operations like loading images from disk for example, this is unavoidable. The best you can do is reuse memory instead of allocating whenever possible
Re:A Closer Look at Android RunTime in Android L by kuschku on Monday November 10, 2014 @04:12AM (#8582643)
On Android you should definitely load the images Async and not load them within the draw call.
Re:A Closer Look at Android RunTime in Android L by rohan404 on Monday November 10, 2014 @04:27AM (#8582674)
Even loaded asynchronously, the calls for allocation still cause lag. Unless I am doing something incorrectly?
Re:A Closer Look at Android RunTime in Android L by on_and_off on Monday November 10, 2014 @05:03AM (#8582751)
You can use inBitmap in order to reuse bitmap instances instead of of allocating new objects. If it fits your use-case, Glide is a very modular lib that implements inBitmap. It is true that you will always have to create some objects though. For example with Glide, a DataFetcher is created with each new image request. You should do your best to keep it at a minimum though, with a focus on creating heavy objects only when it is absolutely necessary.

Other than that, lag can come from many things, so if you lag without GC, the only solution is to profile that part of your app.