Titanium: Memory leak in hello world application

119 views Asked by At

I have the following basic Titanium Alloy application:

index.xml

<Alloy>
    <Window class="container">
        <Label id="label" onClick="doClick">Hello, World</Label>
    </Window>
</Alloy>

index.js

function doClick(e) {
    Alloy.createController('foo', {}).getView().open();
}

$.index.open();

foo.xml

<Alloy>
    <Window>
        <View class="container">
            <Label id="label">Some text in the foo controller!</Label>
        </View>
    </Window>
</Alloy>

foo.js

$.foo.addEventListener('close', function () {
    $.destroy();
    $.off();
});

I then monitored the amount of memory the Android emulator was using DDMS, based on the instructions provided here: http://docs.appcelerator.com/platform/latest/#!/guide/Managing_Memory_and_Finding_Leaks

When the application started the number of objects was: 32,188

When I click the button, and then close the new window by pressing back, and click "cause GC" the number of objects increases to: 32,332

I do this again, it increases to: 32,478

Open and close the window about 8 more times, and it increases to: 34,481

and so on.

Why is this the case and how do I fix this memory leak?

0

There are 0 answers