SparseHistogram Leakage in Cronet

99 views
Skip to first unread message

逸尘

unread,
Mar 31, 2017, 9:02:32 AM3/31/17
to Chromium-dev
Hi,

I am a user of Cronet. I found some memory leakage during my stability test. 

I checked the code, and I think the root cause is that the global StatisticsRecorder g_statistics_recorder_ is not initialized. However, I also noticed that there is a comment: ''As per crbug.com/79322 the histograms are intentionally leaked, so we need to annotate them". It seems to me the leakage under the uninitialized situation is by design.

I am curious about why it is intentionally to leak? Is it harmless? 

Could you please kindly help to explain?

Thanks in advance.



Best Wishes,
JIANG Yichen 

Alexei Svitkine

unread,
Mar 31, 2017, 11:06:03 AM3/31/17
to jiangyi...@gmail.com, Chromium-dev, m...@chromium.org
+mef

You're correct that StatisticsRecorder::Initialize() must be called to prevent leaks. There should be a single instance of a Histogram object for each histogram name - that instance is meant to be leaked (meaning we don't free it at shut down) - but if you don't initialize the StatisticsRecorder then the code will end up creating an instance of the histogram each time you log a histogram and leak those - which would be quite bad.

Looking at the Cronet code itself, it looks like there is a call to StatisticsRecorder::Initialize() - but seems it's done too late - in GetHistogramDeltas() - which would be called only if the histograms are serialized to be uploaded. This is too late because by that point, a lot of histograms could have already been logged/leaked. Ideally, this should be done during Cronet initialization.


--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/70121e5f-c464-4d21-943e-323ed7f3c8f8%40chromium.org.

逸尘

unread,
Mar 31, 2017, 9:40:04 PM3/31/17
to Chromium-dev, jiangyi...@gmail.com, m...@chromium.org
Alexei, 
Thank you so much for the detailed explanation.  

在 2017年3月31日星期五 UTC+8下午11:06:03,Alexei Svitkine写道:

Helen Li

unread,
Apr 3, 2017, 1:52:19 PM4/3/17
to jiangyi...@gmail.com, Chromium-dev, m...@chromium.org
Thanks. I filed https://bugs.chromium.org/p/chromium/issues/detail?id=707836 to track this on Cronet side.

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/9aadad37-a126-4261-a591-9fae7b6b2e11%40chromium.org.
Reply all
Reply to author
Forward
0 new messages