|
|
|
|
|
by richardofyork
4740 days ago
|
|
Are you saying my explanation does not explain the following?
"logIt alone -> str is garbage collected" I don't see why you don't understand why I am saying. My first post explains in detail how closures work and why the issue is not a JS bug, though it is indeed a memory leak. All I can say is that I have explained the overall inner workings of closures in JS, and my explanation covers all the scenarios outlined in the blog post. This is the crux of the matter of the entire blog post: "...str is only referenced in the main body of run, and in doSomethingWithStr. doSomethingWithStr itself gets cleaned up once run ends… the only thing from run that escapes is the second closure, logIt. And logIt doesn’t refer to str at all!
So even though there’s no way for any code to ever refer to str again, it never gets garbage collected!" And I explained why that problem is observed and why closures work the way they do. PS. I will humbly agree to disagree: I think that I have explained all the scenarios outlined in the blog post and you disagree with me. This is not a problem; there is nothing wrong with disagreeing. |
|