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)?
-
5Garbage collection is not implemented in JavaScript code, but is built-in to the language runtime (browser, node.js, V8, etc.).Brandon– Brandon2013-05-18 18:22:12 +00:00Commented May 18, 2013 at 18:22
-
@Brandon That's why I'm asking this question.Ikrom– Ikrom2013-05-18 18:36:01 +00:00Commented May 18, 2013 at 18:36
Add a comment
|
1 Answer
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.