[英]PyV8 disable automatic garbage collection
I'm having an issue which seems to be related with the way Python & PyV8's garbage collection interact. 我遇到的问题似乎与Python和PyV8的垃圾收集交互方式有关。 I've temporarily solved the issue by disabling python's garbage collection, and calling gc.collect
and PyV8.JSEngine.collect
together every few seconds when no JavaScript is being run. 我暂时通过禁用python的垃圾收集来解决这个问题,并且在没有运行JavaScript时每隔几秒就调用gc.collect
和PyV8.JSEngine.collect
。 However, this seems like a pretty hackish fix... in particular, I'm worried PyV8
might decide to collect at an inopportune time and cause problems, anyway. 然而,这似乎是一个非常糟糕的修复...特别是,我担心PyV8
可能会决定在不合时宜的时间收集并导致问题,无论如何。 Is there any way to disable PyV8's automatic garbage collection for good, at least until I have a few days to spend figuring out exactly what is going on and thus to actually fix the issue? 有没有什么方法可以很好地禁用PyV8的自动垃圾收集,至少在我花几天时间来确定究竟发生了什么并从而真正解决问题之前?
It's possible to disable garbage collection for good by changing the source code of V8. 可以通过更改V8的源代码来禁用垃圾收集。
In V8's source, edit src/heap.cc, and put a return statement in the beginning of Heap::CollectGarbage. 在V8的源代码中,编辑src / heap.cc,并在Heap :: CollectGarbage的开头放置一个return语句。
Other than that, it's not possible (AFAICT): V8 will always invoke garbage collection when it's about to run out of memory. 除此之外,它是不可能的(AFAICT):当V8即将耗尽内存时,它将始终调用垃圾收集。 There is no (configurable) way to not have it do that. 没有(可配置的)方法没有这样做。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.