Opening same window multiple time causes failure of application.

You must Login before you can answer or comment on any questions.

Hi,in my android application I want to render same window with different user data multiple times.My code structure looks like:

//app.js
 
data:[
        {title:"Row 1"},
        {title:"Row 2"},
        {title:"Row 3"},
        {title:"Row 4"},
        {title:"Row 5"}
    ]   
 
Ti.include('profile.js')
profile_variables1.profile_dis1(username,data);
// profile.js
var profile_variables1 = {};
 
(function(){
profile_variables1.profile_dis1 = function(username,data)
{
    profile_variables1.userwin1 = Titanium.UI.createWindow(
    {
        backgroundColor:'#f8f8f8',
    });
    feed_item_table = Ti.UI.createTableView(
    {
        width:Ti.Platform.displayCaps.platformWidth,
        backgroundColor:'transparent',
        separatorColor: '#ccc',
        hasChild:true,
    });
    feed_item_table.setData(data);
    profile_variables1.userwin1.add(feed_item_table);
    profile_variables1.userwin1.open();
 
    feed_item_table.addEventListener('click',function(e)
    {
        data:[
                 {title:"Row"+e.index},
                 {title:"Row"+e.index},
                 {title:"Row"+e.index},
                 {title:"Row"+e.index},
                 {title:"Row"+e.index}          
              ]
        Ti.include('userinfo.js')
        user_dis1(username,data);
    })
}
}();
(function(){
user_dis1 = function(username,data)
{
       user_info1 = Titanium.UI.createWindow(
           {
             backgroundColor:'#f8f8f8',
           });
       user_info1.open();
 
    // display some data here......
    table.addEventListener('click',function(e)
    {
        Ti.include('profile.js')
        profile_variables1.profile_dis1(username,data);
    }
}
}();
In the above code I want to render same window with different data.more look like A-B-A-B-A-B.... It's working fine,My application display all window properly but allocated memory continuously growing.In main code of application I am also displaying image in every row.after few clicks my application closed forcefully; and error in debugger is out of memory error bitmap size exceeds VM budget. How to handle this situation.My application get closed because of this error.. Need help. Thank you.....

1 Answer

you will need to close your windows when you open the next one. clearing out the memory.

The way windows work is to stack them ontop of each other. so if you open a then b then a you will actually have 3 windows open. so you ned to open a then close a and open b then close b and open a.. if that makes sense.

This also means that to use the back button you will have to capture the android:back event and build your own back handler functionality.

Hope this helps

t.

— answered 1 year ago by Trevor Ward
answer permalink
2 Comments
  • But if the sequence is like A-B-A and when i click back button i need sequence in reverse order mean don't want to loose previous window.In such cases what is the best way to implement such flow of window. I tried with u r solution that removing previous window and open next window but ultimately my previous get removed which I don't want. any solution.

    — commented 1 year ago by nilesh kashid

  • Actually if your loading heavy windows.. That is lots of info on in a window, you do need to close them. Or your application will run out of memory.

    You will need to keep an array of the previously opened windows (Not the window object) but a reference to the function which opens it. Then call a routine which is fired by the back button to close the current window and open a new window but using the parameters in the back array.

    I am working on a skeleton of this structure for a workshop I am running, but it isn't ready yet, or I would provide it to you. WIll let you know when it is done.

    — commented 1 year ago by Trevor Ward

Your Answer

Think you can help? Login to answer this question!