gpt4 book ai didi

javascript - Chrome 使用了 JSHeapSize 属性

转载 作者:搜寻专家 更新时间:2023-11-01 04:25:09 26 4
gpt4 key购买 nike

首先,我浏览了互联网,发现它的文档非常糟糕。在我的代码中的某个地方,我有一个很大的内存泄漏,我正在尝试跟踪并在使用之后:

window.performance.memory.usedJSHeapSize 

看起来该值保持在 10MB 的同一水平,但事实并非如此,因为当我们与此处可见的值进行比较时:

chrome://memory-internals/

或者如果我们查看 devTools 中的时间轴,我们可以看到很大的不同。有没有人遇到过类似的问题?我是否需要手动更新这些值(以运行“更新”、“测量”等命令?)

关注本主题: Information heap size看起来这个值增加了某个步骤,我们能以某种方式看到它是什么或修改它吗?在我的例子中,我现在看到的页面大约有 10MB,30 分钟后大约有 400MB,半小时后页面会崩溃。伙计们有什么想法吗?

(为什么代码泄漏是另一个问题,请在我尝试使用此变量创建某种测试时处理这个问题)。

最佳答案

WebPlatform.org 文档中有一段对此进行了解释:

The values are quantized as to not expose private information to attackers. If Chrome is run with the flag --enable-precise-memory-info the values are not quantized.

http://docs.webplatform.org/wiki/apis/timing/properties/memory

因此,默认情况下,数字并不精确,并且每 20 分钟才更新一次!这应该可以解释为什么您的电话号码没有改变。如果您使用标志,数字将是准确的和最新的。

WebKit commit message解释:

This patch adds an option to expose quantized and rate-limited memory
information to web pages. Web pages can only learn new data every 20
minutes, which helps mitigate attacks where the attacker compares two
readings to extract side-channel information. The patch also only
reports 100 distinct memory values, which (combined with the rate
limits) makes it difficult for attackers to learn about small changes in
memory use.

关于javascript - Chrome 使用了 JSHeapSize 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25166051/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com