Memory Management?


#1

Hey fusers, in JS, do we need to “unallocate” a var when we’re done using it?
e.g.

  var something = 1234; 
  var somethingElse = 4321;
  var somethingMore = 100;
  var result = 0;
  switch (input) {
    case 1: result = input + something;
      break;
    case 2: result = input + something + somethingElse;
      break;
  }
  result *= 0.15 + somethingMore;

  //unallocate
  something = null;
  somethingElse = null;
  somethingMore = null;

  return result;
}

#2

I don’t think it’s necessary inside a function because garbage collection deals with them.


#3

Humm, the following scientific article definitely will help you :wink:
https://moduscreate.com/blog/dynamic-memory-and-v8-with-javascript/