November 04, 2005 Walter : 2 questions about your JavaScript engine | ||||
---|---|---|---|---|
| ||||
I've been using your JS engine for a while and have couple questions. Can you please give me some hints? 1. I've a C++ object derived from Dobject exposed to JS. When the program ends, I've tried to use mem.fullcollect() and the object seems to be deleted but the destructor doesn't get called. Therefore a memory leak occors if I need to free some momory in the destructor. 2. I've loaded JS engine in thread A and tried to call a JS function from thread B it seems like the engine doesn't like it since the thread context is different. Is there a way to switch JS calling thread context then make the call across thread successfully? Thanks in advance, adzheng |
November 05, 2005 Re: Walter : 2 questions about your JavaScript engine | ||||
---|---|---|---|---|
| ||||
Posted in reply to adzheng | "adzheng" <adzheng_member@pathlink.com> wrote in message news:dkgro6$3g5$1@digitaldaemon.com... > I've been using your JS engine for a while and have couple questions. Can you > please give me some hints? > > 1. I've a C++ object derived from Dobject exposed to JS. When the program ends, > I've tried to use mem.fullcollect() and the object seems to be deleted but the > destructor doesn't get called. Therefore a memory leak occors if I need to free > some momory in the destructor. You can use GC::setFinalizer to run some custom code when the object is free'd by the GC. > 2. I've loaded JS engine in thread A and tried to call a JS function from thread > B it seems like the engine doesn't like it since the thread context is different. Is there a way to switch JS calling thread context then make the call > across thread successfully? The engine is designed around the 'apartment thread' model, where the engine thread contexts are all distinct from each other. Be careful crossing thread boundaries, as the GC instances don't scan or know about each other. |
Copyright © 1999-2021 by the D Language Foundation