Hi Vyacheslav, I see your point.
I don't use separate Isolate for each thread and all tasks use function objects compiled in the global Context/Isolate. This might be a trouble of course, but I was not sure there is a good way to create a function object in main Context and then transfer it to another Isolate/Context. Essentially I wanted to achieve following usage: // thread function function foo () {} // starts execution in a separate thread task(foo); I do make them run exclusively (at least I hope I do) by using Locker locker; Locker::StartPreemption(preemption_interval); HandleScope scope; context = Context::New(); context->Enter(); The code is in a fork from nodejs.You can see the code here: https://github.com/bfrancojr/node/blob/node-task/src/node_task.cc The funny part is that if I create just a couple of threads the memory is stable, while I call V8::IdleNotification() every 5 sec. If I increase the number of tasks to 100 it will start to grow and the process will run out memory. However If I start to call V8::IdleNotification() every 0.3 seconds it fixes it again. I've got a feeling the v8 treats the GC as one of the tasks, meaning that the more tasks I create the more time is allocated to 'garbage producers' and the smaller is a relative portion of time for GC. May be I am wrong. So the questions are: 1. Can I transfer an function object from script compiled in global context and main thread Isolate into the other thread's Isolate and execute there? 2. If not, Is what I am doing a valid v8 API usage at all? What could be other ways to trigger GC more often? Thanks, Dennis On Aug 31, 12:44 am, Vyacheslav Egorov <vego...@chromium.org> wrote: > Hi Dennis, > > V8's GC is stop-the-world type so you don't have to do anything > special to make it "keep up". If you are getting OOM that most > probably means you have a leak somewhere. Try tracing GC with > --trace-gc flag to see how heap grows. > > Also you can't run JavaScript in parallel on V8 unless you create > several isolates. > > If you are using a single isolate from many threads you have to ensure > that only one thread is executing JS at the given moment. > > -- > Vyacheslav Egorov > > On Wed, Aug 31, 2011 at 2:28 AM, Dennis H <gluck...@gmail.com> wrote: > > Dear v8 Developers, > > > I am relatively new to v8 internals, but here is what I found: > > I tried to create an app which has multiple tasks running in parallel. > > The v8::internal::Thread API seems to work fine, the trouble is I > > didn't find a good way to make garbage collection to keep up. > > > I do call the V8::IdleNotification() in the main event loop > > periodically, but it doesn't scale if number of threads is getting > > bigger. Essentially If I create a lot of tasks, the process would > > reliably run out of memory pretty quick. > > > How is the garbage collection supposed to be handled correctly with > > multiple threads? > > > I used v3.4.14. > > > Thanks, > > Dennis > > > -- > > v8-users mailing list > > v8-users@googlegroups.com > >http://groups.google.com/group/v8-users -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users