Indeed. Great find. The implementation for timeEnd in production is fine
though :)

I'll upload a CL.

Yang

On Mon, Feb 22, 2021 at 10:55 AM Mathieu Schroeter <gamesover...@gmail.com>
wrote:

>
> Hello,
>
> There is a memory leak when using console.time / console.timeEnd.
>
> const uniqId = `my label ${newUUID}`;
> try {
>   console.time(uniqId);
>   /* ... */
> } finally {
>   console.timeEnd(uniqId);
> }
>
> It leaks and it's a major problem when it's used intensively with new
> uniqId every time.
>
> See https://github.com/v8/v8/blame/master/src/d8/d8-console.cc#L97 (
> console.timeEnd)
>
> auto find = timers_.find(string);
> if (find != timers_.end()) {
>    delta = now - find->second;
> }
> printf("console.timeEnd: %s, %f\n", *utf8, delta.InMillisecondsF());
>
> Here we can see that the entry is not removed from the timers_ map. I
> suggest to erase the entry just with timers_.erase(string) when find !=
> timers_.end().
>
> Regards,
> Mathieu Schroeter
>
> --
> --
> v8-dev mailing list
> v8-dev@googlegroups.com
> http://groups.google.com/group/v8-dev
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to v8-dev+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/v8-dev/19275c3a-31a3-46ff-9a28-a385508ccaa2n%40googlegroups.com
> <https://groups.google.com/d/msgid/v8-dev/19275c3a-31a3-46ff-9a28-a385508ccaa2n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
-- 
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
--- 
You received this message because you are subscribed to the Google Groups 
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-dev/CAFSTc_gAsnkLbvHif1djX99ax4dfB5_3XjjRPu3yH6wzk4fJWw%40mail.gmail.com.

Reply via email to