Should I avoid creating JSContexts in global queues?

倖福魔咒の 提交于 2019-12-03 16:53:42

Luckily it's open source!

http://www.opensource.apple.com/source/JavaScriptCore/JavaScriptCore-7534.57.3/wtf/OSAllocatorPosix.cpp

void* OSAllocator::reserveAndCommit(size_t bytes, Usage usage, bool writable, bool executable, bool includesGuardPages)

tries to allocate a virtual machine, by allocating some memory

result = mmap(result, bytes, protection, flags, fd, 0);
    if (result == MAP_FAILED) {
       ...
            CRASH();
    }

the memory allocation fails and the app crashes.

Sooooo my best guess would be that this issue is popping up, due to a low memory situation.

How many of these are you allocating?

I experienced a similar issue. Ultimately the extra JavaScriptCore::BlockFree threads were a symptom of the JSContext not getting released. I'd suggest checking to make sure your JSVirtualMachine and JSContext are getting released at the end of execution.

Also as an aside, I am now successfully creating many JSVirtualMachines (1000+ during a run) without any issue, so I don't think that there is a problem with this unless you need a lot of these to run concurrently (like 50+).

Hope that helps!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!