From: hjhun <36876573+hjhun@users.noreply.github.com> Date: Mon, 8 Aug 2022 22:26:13 +0000 (+0900) Subject: [Applications.Common] Fix OnLowMememory (#4470) X-Git-Tag: accepted/tizen/unified/20231205.024657~806 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7b9784b0f1d52f43b6a9d452db0cef8c9c149b80;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [Applications.Common] Fix OnLowMememory (#4470) This patch adds if conditions for registering the GC timer. If the LowMemoryStatus of the LowMemoryEventArgs of the OnLowMemory is SoftWarning or HardWarning, the timer will be registered. Signed-off-by: Hwankyu Jhun --- diff --git a/src/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs b/src/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs index 26b8284..3b0a4ac 100644 --- a/src/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs +++ b/src/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs @@ -219,14 +219,17 @@ namespace Tizen.Applications protected virtual void OnLowMemory(LowMemoryEventArgs e) { LowMemory?.Invoke(this, e); - double interval = new Random().Next(10 * 1000); - if (interval <= 0) - interval = 10 * 1000; - - sTimer = new System.Timers.Timer(interval); - sTimer.Elapsed += OnTimedEvent; - sTimer.AutoReset = false; - sTimer.Enabled = true; + if (e.LowMemoryStatus == LowMemoryStatus.SoftWarning || e.LowMemoryStatus == LowMemoryStatus.HardWarning) + { + double interval = new Random().Next(10 * 1000); + if (interval <= 0) + interval = 10 * 1000; + + sTimer = new System.Timers.Timer(interval); + sTimer.Elapsed += OnTimedEvent; + sTimer.AutoReset = false; + sTimer.Enabled = true; + } } private static void OnTimedEvent(Object source, ElapsedEventArgs e)