What's the problem with adding new Date () to the array and memory can't be reclaimed?

Happy New year, everyone. How many codes do you want to eat?

setTimeout(test2, 3000)
function test2 () {
  var leak = []
  for (var i = 0; i < 2000000; iPP) {
    leak.push(new Date())
  } //  IE  267M test1  null 
  leak = null //  null 
}

setTimeout(test3, 3000)
function test3 () {
  var leak = []
  for (var i = 0; i < 10000000; iPP) { // 
    leak.push(" new Date() ")
  } //  IE  40M  push  124M 41.7M
}

setTimeout(test4, 3000)
function test4 () {
  for (var i = 0; i < 10000000; iPP) {
    var a = new Date()
  } //  40~50M  new Date() 
}
Jun.08,2022

still works

it is better to wait for 40 10s

then compare the code with the comment leak = null
to observe the change in waiting time (maybe there is a change, I don't know, you can hang up all afternoon to see if the memory has been reduced (compressed?) )

Menu