Memory leak with console.time / console.timeEnd

119 views
Skip to first unread message

Mathieu Schroeter

unread,
Feb 22, 2021, 4:55:41 AM2/22/21
to v8-dev

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.


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

Yang Guo

unread,
Feb 22, 2021, 6:50:49 AM2/22/21
to v8-...@googlegroups.com
Indeed. Great find. The implementation for timeEnd in production is fine though :)

I'll upload a CL.

Yang

--
--
v8-dev mailing list
v8-...@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+un...@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.
Reply all
Reply to author
Forward
0 new messages