Performance Warning: Static Field Leaks
Categories
(GeckoView :: General, enhancement, P5)
Tracking
(Not tracked)
People
(Reporter: fluffyemily, Unassigned, Mentored)
References
(Blocks 1 open bug)
Details
(Keywords: good-first-bug, Whiteboard: [lang=java])
Attachments
(2 files)
A static field will leak contexts. Non-static inner classes have an implicit reference to their outer class. If that outer class is for example a Fragment or Activity, then this reference means that the long-running handler/loader/task will hold a reference to the activity which prevents it from getting garbage collected. Similarly, direct field references to activities and fragments from these longer running instances can cause leaks. ViewModel classes should never point to Views or non-application Contexts. Affected Classes: GeckoAppShell GeckoBatteryManager GeckoMediaDrmBridgeV21 GeckoNetworkManager GeckoSystemStateListener
Comment 1•6 years ago
|
||
Some/most/all? (definitively the GeckoBatteryManager and GeckoNetworkManager) of those are singletons that are intended to live as long as the app itself and only hold onto an *application* context.
Updated•6 years ago
|
Updated•5 years ago
|
Updated•2 years ago
|
Comment 3•1 year ago
|
||
- mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsPlayer.java:49: Do not place Android context classes in static fields (static reference to DefaultBandwidthMeter which has field context pointing to Context); this is a memory leak
- mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV21.java:517: This AsyncTask class should be static or leaks might occur (org.mozilla.gecko.media.GeckoMediaDrmBridgeV21.PostRequestTask)
- mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoNetworkManager.java:47: Do not place Android context classes in static fields (static reference to GeckoNetworkManager which has field mContext pointing to Context); this is a memory leak
Adding @SuppressLint("StaticFieldLeak")
and use static class for AsyncTask.
Hello!
I am new to contribute to open source projects.
I just wanted to ask whether this task could be assigned to me so that I can try to solve it and start my contributing journey.
Comment 5•1 year ago
|
||
(In reply to Yash from comment #4)
Hello!
I am new to contribute to open source projects.
I just wanted to ask whether this task could be assigned to me so that I can try to solve it and start my contributing journey.
Assigned.
Comment 6•10 months ago
|
||
This good-first-bug hasn't had any activity for 2 months, it is automatically unassigned.
For more information, please visit BugBot documentation.
Comment 7•9 months ago
|
||
If this bug is still open and unassigned, may i try to fix it?
Comment 8•9 months ago
|
||
(In reply to Hardik Koul from comment #7)
If this bug is still open and unassigned, may i try to fix it?
Yes, see comment #3.
Comment 9•9 months ago
|
||
(In reply to Makoto Kato [:m_kato] from comment #8)
(In reply to Hardik Koul from comment #7)
If this bug is still open and unassigned, may i try to fix it?
Yes, see comment #3.
Sure , thanks. Starting off with setting the repo up in my local.
Comment 10•9 months ago
|
||
Hey Makoto,
I am done with mercurial and git hannibal setup, but while fetching remote , im getting this error
Fetching central
fatal: repository 'https://hg.mozilla.org/mozilla-central/' not found
error: Could not fetch central
Fetching inbound
fatal: repository 'https://hg.mozilla.org/integration/mozilla-inbound/' not found
error: Could not fetch inbound
are the URLs correct for the repos?
Comment 11•9 months ago
•
|
||
What document do you reference? https://github.com/glandium/git-cinnabar/wiki/Mozilla:-A-git-workflow-for-Gecko-development is better.
Comment 12•9 months ago
|
||
(In reply to Makoto Kato [:m_kato] from comment #11)
What document do you reference? https://github.com/glandium/git-cinnabar/wiki/Mozilla:-A-git-workflow-for-Gecko-development is better.
Thanks, i was referring this one : https://firefox-source-docs.mozilla.org/mobile/android/geckoview/contributor/mc-quick-start.html
Comment 13•9 months ago
|
||
Updated•9 months ago
|
Comment 14•9 months ago
|
||
Comment 15•9 months ago
|
||
Here is the patch with the changes suggested : (https://phabricator.services.mozilla.com/D185046)
however im aware suppressing the Lint warning is not an optimal way to solve this memory leak issue, let me know if i can try to figure out any optimal solution for that.
Comment 16•9 months ago
|
||
also apologies for submitting a duplicate patch with just a white space change, please delete that if possible.
Comment 17•8 months ago
|
||
Any update on this ??
Comment 18•8 months ago
|
||
(In reply to Hardik Koul from comment #17)
Any update on this ??
https://phabricator.services.mozilla.com/D185046's status is "Changes Planned". So this isn't reviewable status. If this is ready for code review, please change status to "Needs Review".
Comment 19•8 months ago
|
||
(In reply to Makoto Kato [:m_kato] from comment #18)
(In reply to Hardik Koul from comment #17)
Any update on this ??
https://phabricator.services.mozilla.com/D185046's status is "Changes Planned". So this isn't reviewable status. If this is ready for code review, please change status to "Needs Review".
Hey, sorry was not aware of that process, have updated the status now to "Needs Review" https://phabricator.services.mozilla.com/D185046
Updated•8 months ago
|
Comment 20•6 months ago
|
||
This good-first-bug hasn't had any activity for 2 months, it is automatically unassigned.
For more information, please visit BugBot documentation.
Description
•