简体   繁体   English

我能知道JavaScript中的函数调用使用了多少内存吗?

[英]Can I know how much memory is used by a function call in JavaScript?

I'd like to know how much memories are used during a single function call, what should I do? 我想知道在单个函数调用期间使用了多少内存,我该怎么办?

I'm not developing in node.js environment, so it would be better to know if there's anyway to do it in plain vanilla js. 我不是在node.js环境中进行开发,因此最好知道是否可以在普通香草js中进行。

Chrome dev tools have excellent tools to monitor both performance and memory used. Chrome开发人员工具具有出色的工具,可以同时监视性能和所使用的内存。 Hit 'F12' and check the 'Performance' and 'Memory' tabs. 点击“ F12”并检查“性能”和“内存”选项卡。

The "Record allocation profile" option should show memory allocations from your javascript functions. “记录分配配置文件”选项应显示您的javascript函数的内存分配。

You can also follow this article on a how to step by step tutorial. 您也可以按照文章在如何一步一步的教程。

This falls in the category of "manually" though, not programmatically but it could still be helpful. 虽然这属于“手动”类别,但不是编程方式,但仍可能会有所帮助。

Paul Irish has also released memory-stats.js , which I guess can be used to measure memory allocated by the Javascript engine but in no way you can corelate it to a function in specific. 保罗·爱尔兰(Paul Irish)还发布了memory-stats.js ,我猜它可以用来衡量Javascript引擎分配的内存,但决不能将其核心化为特定的函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM