0

Admittedly this stems from my lack of deep understanding of closures. I found myself with a memory leak and am wondering if this bit of code has anything to do with it. There does not seem to be a destructor I can manually call in the documentation for these typed arrays:

  myMethod: function() {
    // Create a new array on the heap
    var someData = new Uint8Array(32);
    someData[0] = 1;
    someData[1] = 2;
    ...

    transferSomeData(someData.buffer, function(succeeded) {
      // Dispose of the array
      someData = []; // HOW TO DELETE?
    });
  }

1 Answer 1

1

No, you don't need to delete them. When the callback function exits, the values will become garbage because they aren't accessible, and the garbage collector will recover them.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.