Are LiveAPI objects instantiated in JS garbage collected ?

Jan 25, 2012 at 3:03pm

Are LiveAPI objects instantiated in JS garbage collected ?

Hi there,

Creating an array of LiveAPI objects, I’d like to know if objects are really killed if I splice all elements of that array.
It doesn’t seem from a performance/efficiency point of view.

Indeed, my liveset is ok, no lag nothing.
I put the device, if I build a lot of callback, it lags a very bit (only the audio meters)
If I click on my button which splices ALL object in the array, it still lags.
If I delete the device, then undo, no more lags.

any infos?

#61448
Jan 25, 2012 at 4:04pm

I would imagine that a formal declaration of array to be null (as opposed to calling methods to remove objects from the patcher) might help.

Could you post your code?

#221672
Jan 25, 2012 at 4:14pm

Problem is:
I have an array with a length of n.

I decide to activate this or that parameters to be listened (= create the corresponding LiveAPI object w/its callback)
It puts it inside the array at the index 3 for instance.

Same with another one at index 5.

Then, I want to remove the object in 3 (= I don’t want max to listen a specific parameter anymore)

tricky.

#221673
Jan 25, 2012 at 4:31pm

I still think my suggestion is worth a try.

#221674
Jan 25, 2012 at 4:45pm

tried. same.

problem isn’t the array but the objects which seem to remain in memory/cpu cycles or whatever.
sounds strange.
first time I experiment that

#221675
Jan 25, 2012 at 5:00pm

Could you post your code pls?

Thanks

Joe

#221676
Jan 25, 2012 at 7:04pm

Live API objects aren’t going to get collected, I think. Id’s are persistent, even if no longer assigned (I asked someone about this before, but perhaps something has changed since then). I don’t know how this figures into memory management within js, though.

One thing you can do is remove the callback from the API by assigning the object.property = 0. This generally gets rid of any overhead I have. Just removing the js object’s assignment does NOT remove the API object itself, afaik.

After rereading your post, I think that’s what you are after: reassign the .property of the object to 0.

a

btw, assignment of the array to null will lead to api errors (or at least it used to, the last time I tried it).

#221677
Jan 25, 2012 at 7:43pm

for sure, it only remove the reference and garbage collection can happen but of course doesn’t free the placeof the LiveAPI objects.
removing the callback doesn’t help a lot as far as I tested.

I asked to Andrew who probably answer here.

thanks for the explorations :)

if you are interested by the purpose, you can check this :

http://julienbayle.net/2012/01/25/my-video-generator-global-architecture/

#221678

You must be logged in to reply to this topic.