Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
rbartley
Specialist II
Specialist II

Qlik Sense Mashup - Unloading Objects from Memory

Hi everyone,

I am having some issues with memory when loading a large number of objects that include GeoAnalytics maps. Can someone tell me how to unload an object once loaded with app.getObject()?

I have experimented with getSessionObject but without any success e.g.:

mapMY5YMY=app.getObject('mapMY5YMY','4fe5658d-f64f-4d2f-8df3-3cf3d697b882').then(function(model){

  strQID= model.id;

  });

app.destroySessionObject(strQID);

Thanks in advance.

Richard

14 Replies
rbartley
Specialist II
Specialist II
Author

Done.  Thanks to you both.

rbartley
Specialist II
Specialist II
Author

Here's some more information that might prove useful to anyone else who needs to exporting the data behind the visualizations that was previously using the app.getObject method.

I originally hit an issue as follows

1) My original code using the app.getObject method I am able to export the data using:

app.getObject(strDivID,strQID).then( function( model )

  { 

  $(strCmdID).prop('onclick',null).off('click');

  $(strCmdID).on('click', function()

  { 

  model.exportData().then(function( reply ) { 

  console.log('qUrlModified', url); 

  console.log('reply', reply); 

  var url = 'http://' + config.host +'/auth'+reply.qUrl;

  window.open(url);

  }); 

  });

  });

2) However, when I replace this with the app.visualization.get() method, I receive an error: "Uncaught TypeError: visModel.exportData is not a function"

app.visualization.get(strQID).then(function(vis){

  vis.show(strDivID);

  visModel=vis.model;

  $(strCmdID).prop('onclick',null).off('click');

  $(strCmdID).on('click', function(visModel)

  { 

  visModel.exportData().then(function( reply ) { 

  console.log('qUrlModified', url); 

  console.log('reply', reply); 

  var url = 'http://' + config.host +'/auth'+reply.qUrl;

  window.open(url);

  });

  });

  });

After looking around on the community site, I noticed that some people had used the exportData method of the Table API, so I tried this and after a bit of further de-bugging, the following works fine:

app.visualization.get(strQID).then(function(vis){

  vis.show(strDivID);

  visModel=vis.model;

  var table = new Qlik.table(visModel); 

  $(strCmdID).prop('onclick',null).off('click');

  $(strCmdID).on('click', function(visModel)

  { 

  table.exportData({download: true});

  });

});

cpomeren003
Partner - Creator II
Partner - Creator II

Hi Richard,

Do you maybe have a working example on how to close an object? I have tried everything in this thread, but I couldn't figure it out.

Thanks in advance!

rbartley
Specialist II
Specialist II
Author

Hi Casper,

Basically, you use model.close() when you want to close the object.

app.getObject(strDivID,strQID).then( function( model )

if(strExport =='y')

{

//configure for export of data

$(strCmdID).prop('onclick',null).off('click');

$(strCmdID).on('click', function()

exportData(model);

$(strCmdID).hide();

});

}

if(strQSType !='extension' && strQSType!='text/image')

{

//unload when navigate away from tab

$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {

  var target = $(e.target).attr("href") // activated tab

  if (target!='#tab'+strHTMLTab)

  {

model.close();

  }

});

}

In the extract above, you will see that model.close() is called where the name of the tab clicked is not the same as that containing the object.  Whenever a tab is clicked I call the function which contains this extract.

I hope that this helps.

cpomeren003
Partner - Creator II
Partner - Creator II

Hi Richard,

Thanks for the reply. The thing is, I understand what you are doing (calling model.close() whenever the name of the tab isn't the same as the tab that contains the specific object. The problem is, I am also working with tabs and I just don't understand how I can make this work. I just can't translate your example to my mashup and I can't tinker with this because it's not really a working example.

Is there maybe a way to show a really simple html/js example that works? Because I am really curious on how you place your QV inside the html and how you replaced the app.getObject.inside your .js.

Thanks again for the help and the fast response.