简体   繁体   中英

JavaScript, will unused arrays affect performance?

I manipulate data using 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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