Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
dionverbeke
Luminary Alumni
Luminary Alumni

Closing an object that was opened with getObject

Hi,

I am currently opening an object in a Mashup with app.getObject().

I am caching this in a javascript array.

How can I remove all these objects from memory and not linking them anymore with Qlik?

Dion

1 Solution

Accepted Solutions
Anonymous
Not applicable

Hello Dion,

The function app.getObject() returns a promise, not a model. In order to bind the variable to the model you need to do something like

  1. app.getObject(containerId, objectId).then(function(model){ 
  2.      var v = model
  3. }) 

And then you could close it.

In order to free that memory in your browser, you would have to point the variable v to either null or undefined and the call the close function on the variable.

View solution in original post

3 Replies
Anonymous
Not applicable

Hello Dion,

I assume that you are storing your objects by doing something similar to the following:

app.getObject(containerId, objectId).then(function(model){

     appObjects.push(model)

})

where appObjects is the array where you store the objects.

Now, all you have to do in order to close the objects is the following:

function closeQlikObjects(){

     appObjects.forEach(function(obj) { obj.close(); })

     appObjects = [];  

}

David

dionverbeke
Luminary Alumni
Luminary Alumni
Author

Hi Yes,

That is what I am currently doing.

I have difficulty to understand the performance charateristics of getObject.

Is this correct:

var v = app.GetObject()

Qlik Allocates memory and links with the model.

When does Qlik release this memory and the linking?

Anonymous
Not applicable

Hello Dion,

The function app.getObject() returns a promise, not a model. In order to bind the variable to the model you need to do something like

  1. app.getObject(containerId, objectId).then(function(model){ 
  2.      var v = model
  3. }) 

And then you could close it.

In order to free that memory in your browser, you would have to point the variable v to either null or undefined and the call the close function on the variable.