When to release RemoteObjects

90 views
Skip to first unread message

David Coles

unread,
Oct 10, 2020, 12:06:15 PM10/10/20
to chrome-debugging-protocol
I've been playing around with the Runtime domain, but now trying to get my head around how Runtime.releaseObject is supposed to work.

It's pretty clear if I make an RPC such as Runtime.evaluate I should be releasing any RemoteObject that I receive, but it's not so clear in other situations such as when received in events are received or exceptions when an exception is thrown.

Looking at the protocol monitor and puppeteer sources it appears that the client is also responsible for releasing objects returned in events (e.g. those in Runtime.consoleAPICalled.array), but what happens if I'm using a stable version of the protocol and don't know how to handle a newer event? 

I would have assumed I needed to release the exception RemoteObject in Runtime.ExceptionDetails, but puppeteer/DevTools appears to ignore them. Are these implicitly released Runtime.discardConsoleEntries?

Thanks!

boris.o...@ub.io

unread,
Oct 10, 2020, 5:02:21 PM10/10/20
to chrome-debugging-protocol
Remote objects are released when execution context is destroyed — this happens whenever frame is reloaded, navigates or closes. So unless you plan on creating hundreds of megabytes worth of objects, I think it's safe to ignore them. Fwiw we ignore them as well.

Cheers,
Boris

David Coles

unread,
Oct 16, 2020, 11:46:54 AM10/16/20
to boris.o...@ub.io, chrome-debugging-protocol
On Sat, 10 Oct 2020 at 14:02, Boris <boris.o...@ub.io> wrote:
Remote objects are released when execution context is destroyed — this happens whenever frame is reloaded, navigates or closes. So unless you plan on creating hundreds of megabytes worth of objects, I think it's safe to ignore them. Fwiw we ignore them as well.

Thanks for the information. My concern is for long-lived sessions that might last several days without the page being reloaded/closed.
Just using Chrome Dev Tools I'm seeing system memory usage creep up by about 500 MB/day which roughly lines up with the rate of console logging (0.5 kB every 100ms).

For my use I'll probably need to be a bit more careful about releasing RemoteObjects or see if we can restart the DevTools session every now and then.

Cheers
David
Reply all
Reply to author
Forward
0 new messages