2

I don't want to create a wheel from scratch. But I am curious if there were JavaScript library named gc.js what would it looks like? How can I write custom garbage collector for JavaScript in JavaScript (if possible)?

2
  • 5
    Garbage collection is not implemented in JavaScript code, but is built-in to the language runtime (browser, node.js, V8, etc.). Commented May 18, 2013 at 18:22
  • @Brandon That's why I'm asking this question. Commented May 18, 2013 at 18:36

1 Answer 1

2

The garbage collection is done by the execution environment of your code. It is not accessible from the JavaScript code itself - at least it is not specified to be, yet an engine can decide to expose a custom interface to the native functions (example for node.js).

If you would write the whole garbage collector in JavaScript, that would imply that your JavaScript engine itself is [partly] written in JavaScript.

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.