Ejecta icon indicating copy to clipboard operation
Ejecta copied to clipboard

Best practices for restarting Ejecta engine in runtime

Open apitaru opened this issue 13 years ago • 2 comments

I was wondering what would be the recommended way (memory leaks wise, etc.) to restart the entire Ejecta engine in runtime and getting a fresh JS runtime environment.

To clarify - I'm not interested in loading other scripts dynamically but simply restarting with the same index.js on a fresh runtime. This will allow me to not worry so much about Garbage Collection during development, yet avoid low memory issues on iOS.

Thanks, Amit

apitaru avatar Aug 21 '13 15:08 apitaru

That's a good question. There's currently no built-in way to do this.

I believe this would have to be implemented in the EJAppViewController.m: release the current EJJavaScriptView and create a new one. The binding function for this could be placed in the EJBindingEjectaCore.m.

I'll look into it in the coming days.

phoboslab avatar Aug 24 '13 09:08 phoboslab

You can now use ejecta.load(file); to restart the whole engine with the given JS file. E.g. to restart with the default index.js:

ejecta.load('index.js');

phoboslab avatar Aug 26 '13 14:08 phoboslab