HomeWildfire Games

Atlas: Updated wxJS to latest SVN version. Made the JS runtime have a greater…

Description

Atlas: Updated wxJS to latest SVN version. Made the JS runtime have a greater lifetime than all the wx windows, to avoid garbage collection problems.
IGUIObject: Cache the JSObject*, to prevent some frequent allocation while running GUI scripts.
JSInterface_IGUIObject: Fixed garbage collection issues.
JSInterface_IGUIObject, ScriptGlue: Changed to the JS_THREADSAFE form of JS_GetClass.
Util: Avoid startup warnings on Linux caused by using unimplemented cpu_* functions that aren't needed for anything important yet.
sysdep/unix: Changed to native line endings.

Details

Committed
philipJun 9 2007, 12:56 AM
Parents
rP5153: Removing old wxJavaScript
Branches
Unknown
Tags
Unknown

Event Timeline

elexis added a subscriber: elexis.Dec 14 2018, 11:17 AM
elexis added inline comments.
/ps/trunk/source/gui/IGUIObject.cpp
506

Is this still (or has it ever been) actually the case?
There is "automatic unrooting on destruction" https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS::PersistentRooted and since PersistendRooted variables are rooted in the JSContext, they should be deleted when the page is closed, i.e. as intended, no? Perhaps this was not the case in 2007 but now is?
(Does this relate to the MEGA TODO from rP141 in Destroy of IGUIObject.h?)

/ps/trunk/source/gui/IGUIObject.h
307

^

smiley added a subscriber: smiley.Dec 14 2018, 11:59 AM
smiley added inline comments.
/ps/trunk/source/gui/IGUIObject.cpp
506

Seems like they are associated with the runtime as opposed to the JSContext.

These roots can be used in heap-allocated data structures, so they are not associated with any particular JSContext or stack. They are registered with the JSRuntime itself, without locking, so they require a full JSContext to be initialized, not one of its more restricted superclasses.

Maybe I am misunderstanding something here?

elexis added inline comments.Dec 18 2018, 3:34 PM
/ps/trunk/source/gui/IGUIObject.cpp
506

Ah yes, I was already equating JSRuntime with JSContext https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Releases/45#Future_Direction

The patch to change it to JS::Heap is simple, but measuring the memory leak isn't.
valgrind + massif is something that was slow and I suspected it won't show conclusive evidence easily.
I have shown allocated memory using ps and called this function GetGuiObjectByName on hundreds of thousands of GUIObjects, but the allocated memory didn't seem to increase.