Closed ciscorucinski closed 9 years ago
Can you tell me a bit more about your test case? The type of document layout you were using, OS version, device, etc.
I have a multiple view-type RecyclerView where there is atmost 1 view with either one of the following ViewHolders. One VH holds your library's DocumentView, and the other VH holds Android's TextView
Android TextView - https://gist.github.com/ciscorucinski/323950d75a3dff17c004 Your DocumentView - https://gist.github.com/ciscorucinski/02b8ba7ca519cd894ed7
With your DocumentView, I am consistently using 15MB more memory based on Android Studio's "Memory Wiew". 86MB vs 71MB. I have started the program clean a few times, and I am consistently getting the same values. Note: in my app, I have either 40 or 60 ImageView's populated and cached that is part of the base-71MB. Your one DocumentView pushes that to 86MB. I assume, that if I add a second DocumentView, the additional memory usage would be much less as most of the 15MB is probably just due to a "heavy" library; however, I have not tested that
Right off the bat, the biggest offender is the set of bitmaps I use in the background to cache text. When designing the library initially, my concern was allow users to have a smooth experience at the cost of memory. However, we can change the default cache settings to reduce memory consumption. But, this will negatively affect user experience. https://github.com/bluejamesbond/TextJustify-Android/blob/master/library/src/main/res/values/attrs.xml#L82
@ciscorucinski Also, can you pls post the results for docview type FORMATTED_TEXT
?
Ok, here you go. I just decided to test it, and I was right, additional views cost very very little.
In fact there might be a tiny 0.03MB increase per DocumentView, but that needs more testing to verify that number.
For FORMATTED_TEXT, there was no difference from the PLAIN_TEXT implementation. Note: all I did was change the constructor to accept one of those two; nothing else changed.
Wow, yes the Caching is what is causing this. For testing, I just decided to go with NO_CACHE and I went from 86.00MB down to 73.22MB 66.78MB. Regular TextView is 71.20MB. GRAYSCALE is the closest to Android's TextView at 71.85MB.
When I get home, I will test the NO_CACHE with my oldest phone (Galaxy Player 5.8 YP-GP1, Android 4.0.4). Right now I don't notice any issues with my Note 4. My DocumentView will be at most a mid-length to semi-long paragraph.
Thanks for collecting the information. Closing this issue since it is expected behavior. Feel free to reopen.
I have done some simple testing of the memory resources of this app and the standard TextView implementation. I only used this app for justification purposes.
This libary, used to replace just one TextView, eats up 15MB of memory. This seems like a lot extra. While there might not be much that you can do, you might be able to make a light-version of this library that focuses on the simple use-cases your library is can be used for - like just justifing text.