tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit bdaf95cfcd584a128b55f1c73a5aa0168d8d23e4
parent aba02a555d33a09bd9449f57feeff351ce7ae34a
Author: Hubert Boma Manilla <hmanilla@mozilla.com>
Date:   Tue, 18 Nov 2025 10:40:32 +0000

Bug 1999829 - [devtools] Fix memory leak of the response content string actors r=devtools-reviewers,jdescottes

With fixing chunked requests, multiple response content events are sent, A long string actor is created
for each response content data sent. If the reponse  has a lot of parts a lot of long string actors are added to the pool
and not cleaned up over time.

This patch cleans up the old actor when a new one is created as the content of the old actor is stale and the new actor
created contains the updated content.

Also let create the actor when the data is fetched from the frontend.

Differential Revision: https://phabricator.services.mozilla.com/D272498

Diffstat:
Mdevtools/server/actors/network-monitor/network-event-actor.js | 23++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/devtools/server/actors/network-monitor/network-event-actor.js b/devtools/server/actors/network-monitor/network-event-actor.js @@ -446,8 +446,23 @@ class NetworkEventActor extends Actor { * The response packet - network response content. */ getResponseContent() { + const content = { ...this._response.content }; + if (this._response.contentLongStringActor) { + // Remove the old actor from the pool as new actor will be created + // with updated content. + this.unmanage(this._response.contentLongStringActor); + } + this._response.contentLongStringActor = new LongStringActor( + this.conn, + content.text + ); + // bug 1462561 - Use "json" type and manually manage/marshall actors to workaround + // protocol.js performance issue + this.manage(this._response.contentLongStringActor); + content.text = this._response.contentLongStringActor.form(); + return { - content: this._response.content, + content, contentDiscarded: this._discardResponseBody, }; } @@ -671,12 +686,6 @@ class NetworkEventActor extends Actor { } this._response.content = content; - content.text = new LongStringActor(this.conn, content.text); - // bug 1462561 - Use "json" type and manually manage/marshall actors to workaround - // protocol.js performance issue - this.manage(content.text); - content.text = content.text.form(); - this._onEventUpdate( lazy.NetworkUtils.NETWORK_EVENT_TYPES.RESPONSE_CONTENT, {