JS堆逐渐上升然后下降。这是内存泄漏吗?

JS heap rises gradually and then falls. Is this a memory leak?

我正在开发一个包含大量代码的应用程序,这对我来说是黑盒子。在调试其他东西时,我注意到如果你在选项卡之间来回切换,旧选项卡 r g

如您所述,根范围内的任何内容都不会被 GC:

Mark-and-sweep algorithm

This algorithm reduces the definition of "an object is not needed anymore" to "an object is unreachable".

This algorithm assumes the knowledge of a set of objects called roots (In JavaScript, the root is the global object). Periodically, the garbage-collector will start from these roots, find all objects that are referenced from these roots, then all objects referenced from these, etc. Starting from the roots, the garbage collector will thus find all reachable objects and collect all non-reachable objects.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management

一般来说,健康的堆看起来与您发布的图表完全一样。如果它没有 return 到(在实用的世界中:接近)GC 之后的基线,那就值得关注了。