OutOfMemoryError when using lists

7 messages - 1176 views

I'm getting out of memory errors when displaying a screen with a list that either has no items in it or if I set the dataprovider to null. Any idea what's wrong ? If I add items to the data provider using addItem() - method, the list displays correctly, but if there are no items added, or I set the data provider to null when loading the screen with the list, I get the OutOfMemoryError.

Arg, strange, could you give me a piece of code to reproduce this problem ?

The basic structure is pretty much same as in Kaprice.

This is the relevant part of the screen design xml - file:

    <scrollcontainer usemarkers="false" style="bg-color:white">
        <list>
            <_renderer>
                <![CDATA[
                <listItem onAction="showDetails">
                    <text>@{lm_name}</text>
                </listItem>
                ]]>
            </_renderer>
            <_items>@{landmarks}</_items>
        </list>
    </scrollcontainer>

And this is the code used to initialize and construct the screen:

            provider.initialize();
            screen = Kuix.loadScreen(CacheBuddyConstants.LANDMARKS_SCREEN, provider);

Where the provider is a instance variable of the Frame - class. Basically this is just like Pad in Kaprice.

The initialize() - method of the provider just uses addItem(LANDMARKS_PROPERTY, landmarkDataProvider) to add the landmark details into the list. But currently the data provider is completely empty. So it doesn't add any items. And it still fails.

The out of memory error also occurs if I call the Kuix.loadScreen - method with null provider. The OutofMemoryError is thrown when I try to display the screen with:

       KuixMIDlet.getDefault().getCanvas().getDesktop().setCurrentScreen(screen);

I thought that I had everything done basically the same way that Kaprice does things. But Kaprice works, and mine doesn't. I tried setting the pad data provider in Kaprice to null also, but it still works correctly.. I'm a bit baffled by this..

 

Ok, your screen contains only the piece of code you put in your post ?

Else could you try to use the WTK Memory Monitor to identify the growing objet type ?

Yes, that's all I have in the screen apart from the system menu entries.

Unfortunately I wasn't able to identify the growing object. I can send you the memory monitor session file at the time the error occurs if that helps.

If you can I would be interest in .mms file, yes.

Nevermind. Just found out what was wrong. I had copied the xml file from another screen that I had done. I forgot that in screen tag there was the focusloop="true" attribute. When there are no focusable components on the screen, it seems that Kuix ends up in an endless loop looking for the next focusable widget. I removed the focusloop="true" and everything started working again.

I guess you could call this a bug.. Because in the end I want to have that focusloop true, as I want the list that is on the screen to loop from bottom to top and vice versa. Now if the list is empty, Kuix will end up in endless loop. If there is stuff in that list, it works ok.