Memory persistence
-
Does onInit fire every time the plugin is opened in the daw? Or does onInit fire once when an instance of the plugin is created in the daw?
Is there a way to specify that some code should fire once when an instance of the plugin is created in the daw?
If I initiate an instance of a plugin which has an empty object, object1, and then I modify that object to contain the string "I am an object", will that string remain in the object if I close the plugin gui in the daw?
-
@TNTHM said in Memory persistence:
Does onInit fire every time the plugin is opened in the daw? Or does onInit fire once when an instance of the plugin is created in the daw?
it fires each time the plugin is opened in the DAW
Is there a way to specify that some code should fire once when an instance of the plugin is created in the daw?
write a flag to a file saying your "once only ever" code has (or has not) run and check it on init to see if you need to run "once only ever" code
If I initiate an instance of a plugin which has an empty object, object1, and then I modify that object to contain the string "I am an object", will that string remain in the object if I close the plugin gui in the daw?
if widgets(like a label) are set to save in preset then the DAW will remember their state. Panels can have a data attribute- and you can keep objects in there...
-
@Lindon no the plugin state remains persistent if you close and reopen the plugin UI and onInit gets only called once.
Opening and closing the editor makes the same thing as opening and closing the interface preview - there is absolutely no data attached to the UI (with the exception of the webview).
-
@Christoph-Hart - er I thought thats what I said...
-
it fires each time the plugin is opened in the DAW
That's a bit ambigous, it could also be understood as "everytime the plugin UI is opened in the DAW". Just making sure nobody's misunderstanding anything here :)
-
@Christoph-Hart @Lindon Thank you for explaining and clarifying. I appreciate it.
-
@Christoph-Hart is it possible to routinely clear the plug-in memory usage without clearing the preset data? I see the method
Engine.getMemoryUsage()
Is there a way to use this to set a max threshold for memory usage?