views:

370

answers:

1

Hi friends, Do anyone know maximum how many screen we can push in an UiApplication without calling popscreen() and what will be the maximum file size of each screen class.

Thanks as Regards Mintu

+6  A: 

UPDATE according to Marc comment

BB Documentation

Cite from How To - Manage UI interactions:

When managing your application screens on the user interface (UI) stack, do not mismatch the pushScreen() and popScreen(). When the BlackBerry smartphone user finishes interacting with the screens, pop screens off the UI stack; otherwise, the display stack continues to grow until the BlackBerry smartphone runs out of memory. You should not use more than a few modal screens at one time, because each screen uses a thread, and you should not pop the screen only once. If you pop a screen too many times, the BlackBerry smartphone trackwheel/trackball and keyboard can become unresponsive.

Cite from What Is - TooManyThreadsError:

A single application can create up to 16 threads. The total number of threads that can exist on a BlackBerry device from all applications is 128. Therefore, if an application has already created 16 threads, the 17th attempt fails and a TooManyThreadsError exception is thrown. Similarly, if there are 128 threads already created on the BlackBerry device and an application attempts to create another thread, a TooManyThreadsError exception is thrown.

Test Application

alt text

class PushScr extends MainScreen {
    static int mScrCount = 0;
    Screen mContext = this;    
    public PushScr() {
        mScrCount++;
        add(new LabelField("screen count: " + mScrCount));
        add(new LabelField("threads count: " + Thread.activeCount()));
        add(new LabelField("memory used: "
                + Memory.getRAMStats().getAllocated()));
    }    
    protected void makeMenu(Menu menu, int instance) {
        super.makeMenu(menu, instance);
        menu.add(new MenuItem("push screen", 0, 0) {
            public void run() {
                Ui.getUiEngine().pushScreen(new PushScr());
            }
        });    
        menu.add(new MenuItem("push modal screen", 0, 0) {
            public void run() {
                Ui.getUiEngine().pushModalScreen(new PushScr());
            }
        });
        if (mScrCount > 1) {
            menu.add(new MenuItem("pop screen", 0, 0) {
                public void run() {
                    Ui.getUiEngine().popScreen(mContext);
                }
            });
        }
    }
}

Conclusion

So in case of modal screens max count is 16 and common size limited by device jvm memory.
Otherwise it's all about device SRAM memory amount.

Max Gontar
I don't think a regular pushScreen() uses a thread per screen - maybe the KB article is referring to screens pushed using the pushModalScreen() method?
Marc Novakowski
Marc, you're correct, only modal screens use separate thread for each one.
Max Gontar