Fix potential OOM problem
Prior to this cl, there's a potential vulnerability to cache huge logging data in the memory. We send the log out when user didn't trigger any event in 1 min. However, if user keep triggering any log event in 1 min, then there's a change to preserve a huge number logs in the device memory. Then, it causes the OOM. The solution is to set a logging threshold, once the current logging number is larger than 150, then we simply send it out immediately and clean the device memory. Test: Log can be sent out after meeting the threshold. Fix: 211323528 Change-Id: I9d507e8d55d6b7f7e682369edf3b5334eb2856ae
This commit is contained in:
@@ -48,6 +48,8 @@ public class SettingsIntelligenceLogWriter implements LogWriter {
|
||||
|
||||
private static final String LOG = "logs";
|
||||
private static final long MESSAGE_DELAY = DateUtils.MINUTE_IN_MILLIS; // 1 minute
|
||||
// Based on the exp, 99.5% users collect less than 150 data in 1 minute.
|
||||
private static final int CACHE_LOG_THRESHOLD = 150;
|
||||
|
||||
private List<SettingsLog> mSettingsLogList;
|
||||
private SendLogHandler mLogHandler;
|
||||
@@ -128,7 +130,8 @@ public class SettingsIntelligenceLogWriter implements LogWriter {
|
||||
mLogHandler.post(() -> {
|
||||
mSettingsLogList.add(settingsLog);
|
||||
});
|
||||
if (action == SettingsEnums.ACTION_CONTEXTUAL_CARD_DISMISS) {
|
||||
if (action == SettingsEnums.ACTION_CONTEXTUAL_CARD_DISMISS
|
||||
|| mSettingsLogList.size() >= CACHE_LOG_THRESHOLD) {
|
||||
// Directly send this event to notify SI instantly that the card is dismissed
|
||||
mLogHandler.sendLog();
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user