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

[chit-chat] Evil Console #1729

Closed
kocoten1992 opened this issue May 23, 2017 · 4 comments
Closed

[chit-chat] Evil Console #1729

kocoten1992 opened this issue May 23, 2017 · 4 comments

Comments

@kocoten1992
Copy link
Contributor

@kocoten1992 kocoten1992 commented May 23, 2017

You know, I love debugging in console, then come this b*ch, it got me real good (when I'm about to hate javascript).

To meet this b*ch, do as follow:

  • Open a new tab (chrome or firefox), and F12 that tab
  • Open Task Manager (or anything that able to see RAM usage)
  • Notice current usage RAM, type in window.x = new Uint8Array(100000000) several times. (don't delete any previous command), just keep paste in and enter.

Hypothetically - when you enter a new window.x = new Uint8Array(100000000), a previous one should be uNrEaChAbLe, because we haven't reference it anywhere therefor there is no way you able to call it out anymore.

Shouldn't it be collected by now ? Take a look of your memory ( 😈 muahahahah)

Now close F12 and open it again, take a look of your memory again ( 👿 )

So exactly what happen ?

Remember before, I told you to not delete previous command, you know why ?

We can't retrieve the previous window.x for sure, but it is still link, the link are the text on the console log. ( 😮 )

window.x = new Uint8Array(100000000) // the text itself are the evil
Uint8Array(100000000) [0, 0, 0…] // the evil

You could try to do it again by delete the text on console, and memory will be release too.

The example above is cute ;) , but consider a more sophisticated where it drive you insane:

  • You download each segment of file (like webseed or use mediasource), you sure that after each download, you delete buffer alright ...... and memory still not release. (while f12 is open - of course)

Try to close f12 and reopen it - for the love of god, the text or even the request in tab network could still link to buffer 😖

@DiegoRBaquero

This comment has been minimized.

Copy link
Member

@DiegoRBaquero DiegoRBaquero commented May 24, 2017

@kocoten1992 I don't really understand this issue in the context of webtorrent, could you explain a bit further?

@kocoten1992

This comment has been minimized.

Copy link
Contributor Author

@kocoten1992 kocoten1992 commented May 24, 2017

@DiegoRBaquero kinda relevant, cause I thought here as like a mini forum for sharing idea and experience in develop webtorrent ... hence this post.

Webtorrent dev will face with big file, just remind that when you open console, it could be the reason that memory won't go away.

@DiegoRBaquero

This comment has been minimized.

Copy link
Member

@DiegoRBaquero DiegoRBaquero commented May 24, 2017

When I close the console it does go away. Even without nulling or deferencing it.

@kocoten1992

This comment has been minimized.

Copy link
Contributor Author

@kocoten1992 kocoten1992 commented May 25, 2017

Ye, the act of close the console actually dereference it, another way is:

// Ctrl + L (clear console - dereference)
// Then go to Memory Tab, click Collect Garbage
// It work too
@feross feross transferred this issue from another repository Sep 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.