Search code examples
androidmemory-leaksappcelerator-titaniumappcelerator-mobileappcelerator-alloy

Solution to memory leak with Appcelerator drawer?


I am using this module (https://github.com/manumaticx/Ti.DrawerLayout) for the drawer in my Android app. However, I am seeing a memory leak in that replacing the centerView results in any previous views being retained. I am seeing the exact same scenario as described in this issue (https://github.com/manumaticx/Ti.DrawerLayout/issues/72), right down to the leaked activities in the memory analyzer. If I keep adding new views to the drawer it will eventually crash with OOM (code is at the bottom).

Now, the issue I linked seems to indicate it is fixed, but when I pull 2.0.0 from gittio (http://gitt.io/component/com.tripvi.drawerlayout) it still has the issue.

Everyone seems to use this drawer, though, and I don't understand how it's useable at all. Has anyone independently discovered a workaround?

Here is my code to exchange the centerview of the drawer.

var controller = Alloy.createController(controllerName, options);
$.drawer.setCenterView(controller.getView());

Solution

  • I was unable to find a solution, so I wrote my own drawer.