Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why have you dereferenced ctx explicitely? #19

Open
Dhruv-Garg79 opened this issue Sep 3, 2023 · 4 comments
Open

Why have you dereferenced ctx explicitely? #19

Dhruv-Garg79 opened this issue Sep 3, 2023 · 4 comments

Comments

@Dhruv-Garg79
Copy link

Hey first of all thanks for this project, I was exploring uWebSockets.js.

I was going through your code and saw that you have explicitly dereferenced ctx = null in setupRouteHandlers.js file.

According to my understanding, it will get dereferenced on it's own when the function block ends.
please correct me If I am wrong.

@a-tonchev
Copy link
Owner

@Dhruv-Garg79 that is correct. But this way I just make the work of the garbage collector a little bit easier 🙂 An this way also other programmers can see - this is the end.

@Dhruv-Garg79
Copy link
Author

But how does that make the work of GC easier?
you have just derefernced it, GC will work the same if you derefernced it yourself, or node.js does it.
GC reclaims the memory for objects that are not reachable(dereferenced), it does not dereference them itself, right?

The other point regarding - this is the end. seems nice.

@a-tonchev
Copy link
Owner

@Dhruv-Garg79 my logic is - GC need a little bit more time to understand when the object is not reachable. This way you tell it directly.

Don't think about this too much, it probably have no difference

@Dhruv-Garg79
Copy link
Author

yeah, got it. Just wanted to understand If I am missing something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants