I have an application just like Pulse and its in beta stage https://play.google.com/store/apps/details?id=com.braindigit.nepal.khabar

I have a main layout which holds a LinearLayout named NewsCategoryHolder and on this layout I dynamically add and remove another layout name CategoryView .This CategoryView contains HorizontalListView and other views. Further for navigation I have implemented ActionbarSherlock Tab and on each click of the tab NewsCategoryHolder will remove all its views and then add CategoryView. Each CategoryView has its own AsyncTask to either load data from server or from database. And on each addition and removal of CategoryView I have removed all its views,assigned its adapters to null and even the Context it holds to null. But as I navigate from Tab to Tab,the memory of the application increases. I feel that it is the case of some memory leaking going on my application. I have gone all the tutorials ,links and videos about MAT and other analyzers,but I couldn't pin point the exact portion from which the app is consuming memory or the point on which GC couldn't collect the object refrences.

I just want to find the location where memory consumption is high,but couldn't be able to do that.I have attached *.hprof http://news.braindigit.com/saved/android3201806337409456011.hprof file and just want some help on its analysis and my application package name is com.braindigit.nepal.khabar

有帮助吗?

解决方案

I found the main reason why memory consumption is high.Rather than from the MAT ,after removing various views from layout and various statements,I found that I am using font from the asset folder which was the main culprit.

headingText.setTypeface(Typeface.createFromAsset(context.getAssets(), DataHolder.FONT_PATH));

So by doing this maybe Context is being referenced or TypeFace is being referenced and was never garbage collected.But removing this line of code fixed all the memory leak issue on my app.

Further this issue can be solved using the technique described here Typeface memory leak

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top