Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Luminary
Luminary

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
bcf
New Contributor III

Re: Closing an object that was opened with getObject

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.

3 Replies
bcf
New Contributor III

Re: Closing an object that was opened with getObject

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

Luminary
Luminary

Re: Closing an object that was opened with getObject

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?

bcf
New Contributor III

Re: Closing an object that was opened with getObject

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.

Community Browser