Reputation: 5123
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)?
Upvotes: 2
Views: 463
Reputation: 665430
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.
Upvotes: 2