Possible memory leak in FB Purity extension



Tech Evangelism
4 years ago
3 years ago


(Reporter: ebaynegs, Unassigned)


Firefox 24

Firefox Tracking Flags

(Not tracked)


(Whiteboard: [MemShrink:P3], URL)


(4 attachments)



4 years ago
User Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36

Steps to reproduce:

Running the latest fb purity browser extension ( https://addons.mozilla.org/en-US/firefox/addon/fb-purity-cleans-up-facebook/ ) for a while, mainly on Facebook's newsfeed, but browsing other parts of the site too (just general facebook usage over a period of time basically)

Actual results:

The memory usage shoots up really high

Expected results:

The memory usage shouldnt shoot up so high, it seems like the add-on has a memory leak.

I'm the developer of the extension, and would be grateful if anyone could have a look at the code and see if they can spot any issues that would cause it, or give me some pointers on how to track down the problem.
Does the memory usage drop back down when the page is closed, or does it accumulate over time? Do you see any facebook compartments in about:compartments after a Facebook page is closed?
Summary: I've noticed a memory leak in my browser extension (FB Purity) can anyone help me track it down? → Possible memory leak in FB Purity extension
When you've reached a point where the memory consumption is "really high", please do "Measure and save" in about:memory and attach the resulting file.  We won't be able to help you without that.  Thanks!
Whiteboard: [MemShrink]
Flags: needinfo?(ebaynegs)
Whiteboard: [MemShrink] → [MemShrink:P3]

Comment 3

4 years ago
Thanks for the advice and pointers, guys. Sorry I havent responded sooner, will follow your guidance, when i get some time, Cheesr.
Flags: needinfo?(ebaynegs)

Comment 4

4 years ago
@Jorge when i close the facebook tab, it frees up about half of the memory it was originally using.

@Nicolas, im having some problems using firefox's about:memory function
using the latest Firefox  beta v26 on windows xp 2gig ram, pentium4 - 2.8Ghz

when i go to the about:memory page and try and run the "Measure" command, i keep getting the following error message popping up.
A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete.

Script: chrome://global/content/aboutMemory.js:1087

I dont get it when i click the "Measure and Save" button, but when i try and load a saved memory report, it just says "Loading" and hangs on that, it never actually finishes loading the report.

I will try again to get a good example of the memory leak, and save the memory report later.
> I dont get it when i click the "Measure and Save" button, but when i try and
> load a saved memory report, it just says "Loading" and hangs on that, it
> never actually finishes loading the report.

That's odd.  I've never heard of that problem before.  Can you attach the offending file so I can try it?

Comment 6

4 years ago
Created attachment 8337425 [details]

its the memory report for the possible memory leak in firefox 26, possibly caused by the fb purity browser extension

Comment 7

4 years ago
i just tried the process again, in the latest 26 beta, and got the same problem. it will measure and save but wont display the results of measure on its own, it just crashes.

ive attached the last memory report i saved as requested

Comment 8

4 years ago
ah just realised that was the greasemonkey script version that i was using, when i submitted the memory report attachment, i will do another one with the firefox extensino version of fbp.

Comment 9

4 years ago
Created attachment 8339140 [details]
this report is one where the virtual memory usage was over 600megs  memory-report.json.gz

this memory report is with only the firefox extension fb purity enabled
> this memory report is with only the firefox extension fb purity enabled

This is a *huge* memory reports file -- 113 MB when uncompressed.  I don't recall ever seeing one nearly this big before.  When I loaded it in about:memory the "Loading..." showed for quite some time, but it eventually displayed the data.

There are vast numbers of entries like this in the notable strings section:
│  │  │  │  │   ├───0.03 MB (00.00%) ++ string(length=4100, copies=2, "<div class="clearfix UFIImageBlockContent _42ef" data-reactid=".r[4690g].[1][3][1]{comment10151752354310880_27352747}.[0].{right}.[0]"><div class="rfloat" data-reactid=".r[4690g].[1][3][1]{comment10151752354310880_27352747}.[0].{right}.[0].{right}"><a href="#" role="button" aria-label="Hide" data-hover="tooltip" data-tooltip-alignh="center" class="uiCloseButton UFICommentCloseButton" data-reactid=".r[4690g].[1][3][1]{comment10151752354310880_27352747}.[0].{right}.[0].{right}.[0]"><img class="img uiCloseButtonHighContrast" src="&#x2f;images&#x2f;chat&#x2f;tab&#x2f;close.png" data-reactid=".r[4690g].[1][3][1]{comment10151752354310880_27352747}.[0].{right}.[0].{right}.[0].[0]"></a></div><div class="" data-reactid=".r[4690g].[1][3][1]{comment10151752354310880_27352747}.[0].{right}.[0].{left}"><div data-reactid=".r[4690g].[1][3][1]{comment10151752354310880_27352747}.[0].{right}.[0].{left}.[0]"><div class="UFICommentContent" data-reactid=".r[4690g].[1][3][1]{comment10151752354310880_27352747}.[0].{right}.[0].{left}.[0].[0]"><a class="UFICommentActorName" href="https:&#x2f;&#x2f;www.facebook.com&#x2f;thatseanbuckley" data-hovercard="&#x2f;ajax&#x2f;hovercard&#x2f;hovercard.php?id=100001115420676&amp;extragetparams=%7B%22hc_location%22%3A%22ufi%22%7D" data-ft="{&quot;tn&quot;:&quot;;&quot;}" data-reactid=".r[4690g].[1][3][1]{comment10151752354310880_27352747}.[0].{right}.[0].{left}.[0].[0].[0][0]">Sean Buckley</a><span data-reactid=".r[4690g].[1][3][1]{comment10151752354310880_27352747}.[0].{right}.[0].{left}.[0].[0].[0][2]"> </span><span data-ft="{&quot;tn&quot;:&quot;K&quot;}" data-reactid=".r[4690g].[1][3][1]{comment10151752354310880_27352747}.[0].{right}.[0].{left}.[0].[0].[0][3]"><span data-reactid=".r[4690g].[1][3][1]{comment10151752354310880_27352747}.[0].{right}.[0].{left}.[0].[0].[0][3].[0]"><span data-reactid=".r[4690g].[1][3][1]{comment10151752354310880_27352747}.[0].{right}.[0].{left}.[0].[0].[0][3].[0].[0]">barnacle style</span></span></span><span data-reactid=".r[4690g].[1][3][1]{comment10151752354310880_27352747}.[0].{right}.[0].{left}.[0].[0].[3]"></span></div><div class="fsm fwn fcg UFICommentActions" data-reactid=".r[4690g].[1][3][1]{comment10151752354310880_27352747}.[0].{right}.[0].{left}.[0].[3]"><span data-reactid=".r[4690g].[1][3][1]{comment10151752354310880_27352747}.[0].{right}.[0].{left}.[0].[3].{metadata}"><span class="UFITimestampViaSource" data-reactid=".r[4690g].[1][3][1]{comment10151752354310880_27352747}.[0].{right}.[0].{left}.[0].[3].{metadata}.[0]"><span data-reactid=".r[4690g].[1][3][1]{comment10151752354310880_27352747}.[0].{right}.[0].{left}.[0].[3].{metadata}.[0].[0]"></span><a class="uiLinkSubtle" href="&#x2f;psibreaker&#x2f;posts&#x2f;10151752354310880?comment_id=27352747&amp;offset=0&amp;total_comments=2" data-ft="{&quot;tn&quot;:&quot;N&quot;}" data-reactid=".r[4690g].[1][3][1]{comment10151752354310880_27352747}.[0].{right}.[0].{left}.[0].[3].{metadata}.[0].[1]"><abbr class="livetimestamp" title="Tuesday, November 26, 2013 at 8:07pm" data-utime="1385496471" data-reactid=".r[4690g].[1][3][1]{comment10151752354310880_27352747}.[0].{right}.[0].{left}.[0].[3].{metadata}.[0].[1].[0]">12 hours ago</abbr></a><span data-reactid=".r[4690g].[1][3][1]{comment10151752354310880_27352747}.[0].{right}.[0].{left}.[0].[3].{metadata}.[0].[2]"> via </span><a class="uiLinkSubtle" href="https:&#x2f;&#x2f;www.facebook.com&#x2f;mobile&#x2f;" data-reactid=".r[4690g].[1][3][1]{comment10151752354310880_27352747}.[0].{right}.[0].{left}.[0].[3].{metadata}.[0].[3]">mobile</a><span data-reactid=".r[4690g].[1][3][1]{comment10151752354310880_27352747}.[0].{right}.[0].{left}.[0].[3].{metadata}.[0].[4]"></span></span></span><span data-reactid=".r[4690g].[1][3][1]{comment10151752354310880_27352747}.[0].{right}.[0].{left}.[0].[3].{likeToggle}{MIDDOT}"> /xB7 </span><a class="UFILikeLink" href="#" role="button" data-ft="{&quot;tn&quot;:&quot;&gt;&quot;}" title="Like this comment" data-reactid=".r[4690g].[1][3][1]{comment10151752354310880_27352747}.[0].{right}.[0].{left}.[0].[3].{likeToggle}{action}">Like</a></div></div></di" (truncated))

and like this:

│  │  │  │  │   ├───0.02 MB (00.00%) ++ string(length=2546, copies=2, "<div data-reactid=".r[302hp].[1][3][1]{comment10152080784256882_31382407}.[0].{right}.[0].{left}.[0]"><div class="UFICommentContent" data-reactid=".r[302hp].[1][3][1]{comment10152080784256882_31382407}.[0].{right}.[0].{left}.[0].[0]"><a class="UFICommentActorName" href="https:&#x2f;&#x2f;www.facebook.com&#x2f;renemillman" data-hovercard="&#x2f;ajax&#x2f;hovercard&#x2f;hovercard.php?id=537842564&amp;extragetparams=%7B%22hc_location%22%3A%22ufi%22%7D" data-ft="{&quot;tn&quot;:&quot;;&quot;}" data-reactid=".r[302hp].[1][3][1]{comment10152080784256882_31382407}.[0].{right}.[0].{left}.[0].[0].[0][0]">Rene Millman</a><span data-reactid=".r[302hp].[1][3][1]{comment10152080784256882_31382407}.[0].{right}.[0].{left}.[0].[0].[0][2]"> </span><span data-ft="{&quot;tn&quot;:&quot;K&quot;}" data-reactid=".r[302hp].[1][3][1]{comment10152080784256882_31382407}.[0].{right}.[0].{left}.[0].[0].[0][3]"><span data-reactid=".r[302hp].[1][3][1]{comment10152080784256882_31382407}.[0].{right}.[0].{left}.[0].[0].[0][3].[0]"><span data-reactid=".r[302hp].[1][3][1]{comment10152080784256882_31382407}.[0].{right}.[0].{left}.[0].[0].[0][3].[0].[0]">Looks like one to avoid, but then again, I avoid all consoles!!</span></span></span><span data-reactid=".r[302hp].[1][3][1]{comment10152080784256882_31382407}.[0].{right}.[0].{left}.[0].[0].[3]"></span></div><div class="fsm fwn fcg UFICommentActions" data-reactid=".r[302hp].[1][3][1]{comment10152080784256882_31382407}.[0].{right}.[0].{left}.[0].[3]"><span data-reactid=".r[302hp].[1][3][1]{comment10152080784256882_31382407}.[0].{right}.[0].{left}.[0].[3].{metadata}"><a class="uiLinkSubtle" href="&#x2f;kat.orphanides&#x2f;posts&#x2f;10152080784256882?comment_id=31382407&amp;offset=0&amp;total_comments=4" data-ft="{&quot;tn&quot;:&quot;N&quot;}" data-reactid=".r[302hp].[1][3][1]{comment10152080784256882_31382407}.[0].{right}.[0].{left}.[0].[3].{metadata}.[0]"><abbr class="livetimestamp" title="Tuesday, November 26, 2013 at 4:35pm" data-utime="1385483717" data-reactid=".r[302hp].[1][3][1]{comment10152080784256882_31382407}.[0].{right}.[0].{left}.[0].[3].{metadata}.[0].[0]">16 hours ago</abbr></a></span><span data-reactid=".r[302hp].[1][3][1]{comment10152080784256882_31382407}.[0].{right}.[0].{left}.[0].[3].{likeToggle}{MIDDOT}"> /xB7 </span><a class="UFILikeLink" href="#" role="button" data-ft="{&quot;tn&quot;:&quot;&gt;&quot;}" title="Like this comment" data-reactid=".r[302hp].[1][3][1]{comment10152080784256882_31382407}.[0].{right}.[0].{left}.[0].[3].{likeToggle}{action}">Like</a></div></d")

I don't know what these are but guess they are due to the extension.  They come in a wide range of lengths.  I would guess that you're somehow accruing this large number of very similar strings somehow.  So it's not a memory leak exactly, just accumulation of repetitive data.

Comment 11

4 years ago
ok, thanks for the info. those strings look like comments on newsfeed posts. i will try and find out if its fbp that is causing it.
Created attachment 8572009 [details]

366 not-yet-accessed tabs without F.B. Purity
Created attachment 8572010 [details]

366 not-yet-accessed tabs with F.B. Purity
The current version of F.B. Purity (12.8.0) appear to create many class objects and non-shared strings which result in significant memory usage, on the order of 230KB/tab. This appears to be a long-standing issue; I initially noticed it with a 9.x version. I am running Firefox Developer Edition.

The difference was 81 MB private bytes and 88 MB vsize with a session with ~360 tabs, measured after restarting while on the about:memory tab, as shown in the above attachments which can be diffed. 
50 MB of the difference is in js-non-window (mostly compartments), 12 MB in heap-overhead, and 9 MB in window-objects (mostly 'class(Function)/objects/gc-heap' and 'class(<non-notable classes>)/shapes/gc-heap').

This is an increase of _21%_ private bytes (390.41 MB vs. 471.59 MB) and _9.5%_ vsize (936.17 MB vs. 1,024.83 MB).
One thing I forgot to mention: restart times are also significantly increased by the presence of F.B. Purity with large numbers of tabs, e.g. it takes around 24 seconds to restart with all of these tabs and get to a usable state vs. 15 seconds.
I poked more at this; it appears to be due to the use of loadFrameScript in bootstrap.js (essentially a wrapper for the main FBP GreaseMonkey script). It isn't anything to do with the FBP script itself.

Commenting out code to force it to use the "GlobalManager" class (which does not use this call) instead of "SlaveDriver" reduces memory/CPU usage. It's loading bootstrap.js once, rather than once per frame. 

I'm suspect this won't work in multiprocessor Firefox; but ideally it wouldn't use resources on tabs which have not yet been loaded. Perhaps someone from Mozilla could offer advice on how to do this?
You need to log in before you can comment on or make changes to this bug.