Are LiveAPI objects instantiated in JS garbage collected ?
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.
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?
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)
I still think my suggestion is worth a try.
problem isn’t the array but the objects which seem to remain in memory/cpu cycles or whatever.
first time I experiment that
Could you post your code pls?
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.
btw, assignment of the array to null will lead to api errors (or at least it used to, the last time I tried it).
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 :
Forums > Max For Live