-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
console: prevent internal timers storage from growing #3562
Conversation
Changes LGTM, although a regression test would be nice. This is a behavior change (semver-major) that gets us in line with what Chrome does. |
Agree with @cjihrig. A test is necessary. Otherwise LGTM though |
@cjihrig @evanlucas the only test I can imagine is one that checks internal |
yea I would say just call |
69162e1
to
d4a62d7
Compare
I have added a test which verifies that |
Should probably use |
@@ -57,6 +57,16 @@ console.timeEnd('hasOwnProperty'); | |||
|
|||
global.process.stdout.write = stdout_write; | |||
|
|||
// verify that console.timeEnd() doesn't leave dead links | |||
var timesMapSize = console._times.size; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, please make this const
too.
d4a62d7
to
3a171f9
Compare
@cjihrig yep! |
@cjihrig @evanlucas Can you explain why this is semver-major? |
Currently, you can reuse a timer, for example after each iteration of a loop. With this change you would have to create a new timer each time. |
@cjihrig do you mean the cases like this: console.time('label');
console.timeEnd('label');
console.timeEnd('label');
console.timeEnd('label'); |
Yes. I'd be willing to bet there are people out there relying on that behavior. |
To be honest I've never thought about such usecase. At least Blink's implementation of |
@Fishrock123 did we decide to move forward with this change? |
+1 for this change, a |
@narqo could you rebase this please. |
The instance of `Console` class doesn't remove links to arrays that come from hrtimer after `timeEnd` had been called.
3a171f9
to
474c066
Compare
🆙 |
LGTM We may also want to stop throwing on |
Currently, console timers that have been ended with timeEnd() are not removed. This has the potential to leak memory. This commit deletes ended timers from the containing Map. PR-URL: #3562 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Thanks! Landed in a5cce79 |
Unintended functionality was removed from console.endTime by nodejs#3562. Prior to that, you could call console.endTime multiple times for the same label.
Unintended functionality was removed from console.endTime by #3562. Prior to that, you could call console.endTime multiple times for the same label. PR-URL: #6454 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Robert Lindstaedt <robert.lindstaedt@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Jeremy Whitlock <jwhitlock@apache.org>
Unintended functionality was removed from console.endTime by #3562. Prior to that, you could call console.endTime multiple times for the same label. PR-URL: #6454 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Robert Lindstaedt <robert.lindstaedt@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Jeremy Whitlock <jwhitlock@apache.org>
Unintended functionality was removed from console.endTime by nodejs#3562. Prior to that, you could call console.endTime multiple times for the same label. PR-URL: nodejs#6454 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Robert Lindstaedt <robert.lindstaedt@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Jeremy Whitlock <jwhitlock@apache.org>
The instance of
Console
class doesn't remove links to arrays that come from hrtimer aftertimeEnd
had been called.As far as I understand, such links won't be collected by v8's gc.