If I have an app that steadily creates and joins threads, is there a good 
way of cleaning up the thread-specific data when a thread terminates? 
Looking at the v8 code, it seems that ThreadManager::FreeThreadResources in 
v8threads.cc would be a place this might happen when called from the Locker 
destructor when top_level_ is set. But maybe for good reason not all 
thread-specific data seems to be cleaned up?

More specifically, as I have lots of threads use an isolate and then 
terminate, their Isolate::PerIsolateThreadData remains queued off 
of Isolate::ThreadDataTable list_. While this is essentially a memory leak, 
even worse, the queue just gets crazy long and the master (so first Isolate 
user) thread's Isolate::PerIsolateThreadData (being at the end) takes crazy 
long to find. And the entire massive queue has to be scanned each time a 
new thread uses the Isolate to determine that the thread does not yet have 
an Isolate::PerIsolateThreadData. Eventually v8 ends up spending most of 
its time scanning the Isolate::PerIsolateThreadData queue. 

The solution would be to be able to get to Isolate::ThreadDataTable::Remove 
for defunct threads but I didn't see a path there from any embedder API 
functions. Is there one? And it looks like might be a few other 
thread-specific bits and bobs that might be left laying around, anyway.

Maybe v8 just isn't built with apps that steadily create and destroy 
thread's in mind and such apps should just use their own thread pool 
managers and avoid allowing threads to terminate? Easy enough to do that 
though it's even easier if we don't have to -- the overhead of creating and 
joining threads is pretty tiny these days, especially relative to the "real 
work" that likely happens on each thread. 

Thanks

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to