Good day!
All objects returned by FireWyrmJS are automatically released after 5 seconds in Chrome, but I need keeping some objects to interact with it. Is is safe to deactivate that releasing at all in chrome-extension scripts? Or may be it is possible to filter some way: what objects to release and what objects to keep?
I have seen retain() and release() methods in chrome-extension javascripts but i need one web page for chrome, ie and firefox, so I hope for better solution.
I return objects from plugin to browser next way:
MyObjectPtr MyPluginAPI::getMyObj()
{
return std::make_shared<MyObject>(m_host);
}
I've debugged it and gotten that destructor of MyObject is being called when web-page is refreshed (in chrome). Is it right? In that case real object in plugin exists, but i can not interact with it in web-page because of 5 sec releasing.
Thanks for any advices.
Unfortunately there is no way to automatically manage garbage collection between javascript and firewyrm because there is no way to be notified when a js object is GC'd. It is definitely not safe to disable that check -- if you do you'll end up with severe memory leaks. Instead you should call
.retain()on the object you want to hold on to (and.release()when you don't need it anymore).