简体   繁体   English

JavaScript,未使用的数组会影响性能吗?

[英]JavaScript, will unused arrays affect performance?

I manipulate data using D3.js. 我使用D3.js处理数据。

I created many arrays to obtain the final array with desired data structure. 我创建了许多数组以获得具有所需数据结构的最终数组。

As each arrays contain thousands of objects each, I was wondering if they will affect the browser's performance even though these arrays are no longer in use? 由于每个数组包含数千个对象,因此我想知道即使不再使用这些数组,它们是否也会影响浏览器的性能?

Will emptying/deleting these arrays improve the performance? 清空/删除这些数组会提高性能吗?

As there are many different libraries and events (filters, onclick, etc) used, it is hard for me to accurately determine the performance. 由于使用了许多不同的库和事件(过滤器,onclick等),因此我很难准确确定性能。

Eg 例如

array1.forEach(function(d){
d.v1 = +d.v1;
...
});

array2 = d3.nest().key(function(d) { return d.state; }).entries(array1);

array3 = d3.nest().key(function(d) { return d.state; }).rollup(...).9entries(array1);

array4 = [];
for (i in array3) {
...
array4.push(...) };

array5
...
array10

After referring to the comments, I gathered that unused arrays will get garbage-collected automatically. 在引用注释之后,我收集到未使用的数组将自动进行垃圾收集。 Hence, they will not affect the memory. 因此,它们不会影响内存。

I hereby close this question. 我在此结束这个问题。

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

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