Beispiel #1
0
 private void MemoryManager_AppMemoryUsageLimitChanging(object sender, AppMemoryUsageLimitChangingEventArgs e)
 {
     if (MemoryManager.AppMemoryUsage >= e.NewLimit)
     {
         ReduceMemoryUsage(e.NewLimit);
     }
 }
Beispiel #2
0
 private void MemoryManagerOnAppMemoryUsageLimitChanging(object sender, AppMemoryUsageLimitChangingEventArgs args)
 {
     if (MemoryManager.AppMemoryUsage > args.NewLimit)
     {
         ReduceMemoryUsage();
     }
 }
Beispiel #3
0
 private async void OnAppMemoryUsageLimitChanging(object sender, AppMemoryUsageLimitChangingEventArgs e)
 {
     status.Log("AppMemoryUsageLimitChanging");
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         GetUsage();
     });
 }
Beispiel #4
0
 /// <summary>
 /// 当应用的内存限制量改变时的操作
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void AppMemoryUsageLimitChanging(object sender, AppMemoryUsageLimitChangingEventArgs e)
 {
     Debug.WriteLine("[MemoryUsage]内存限制量发生了改变");
     if (MemoryManager.AppMemoryUsage >= e.NewLimit)
     {
         ReduceMemoryUsage();
     }
 }
Beispiel #5
0
 /// <summary>
 /// Handle system notifications that the app has increased its
 /// memory usage level compared to its current target.
 /// </summary>
 /// <remarks>
 /// The app may have increased its usage or the app may have moved
 /// to the background and the system lowered the target for the app
 /// In either case, if the application wants to maintain its priority
 /// to avoid being suspended before other apps, it may need to reduce
 /// its memory usage.
 ///
 /// This is not a replacement for handling AppMemoryUsageLimitChanging
 /// which is critical to ensure the app immediately gets below the new
 /// limit. However, once the app is allowed to continue running and
 /// policy is applied, some apps may wish to continue monitoring
 /// usage to ensure they remain below the limit.
 /// </remarks>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void MemoryManager_AppMemoryUsageLimitChanging(object sender, AppMemoryUsageLimitChangingEventArgs e)
 {
     // If app memory usage is over the limit, reduce usage within 2 seconds
     // so that the system does not suspend the app
     if (MemoryManager.AppMemoryUsage >= e.NewLimit)
     {
         ReduceMemoryUsage(e.NewLimit);
     }
 }
Beispiel #6
0
 private void MemoryManager_AppMemoryUsageLimitChanging(object sender, AppMemoryUsageLimitChangingEventArgs e)
 {
     if (MemoryManager.AppMemoryUsage >= e.NewLimit)
     {
         ReduceMemoryUsage(e.NewLimit);
     }
     Debug.WriteLine("Memory usage limit changing from "
                     + (e.OldLimit / 1024 / 1024) + "M to "
                     + (e.NewLimit / 1024 / 1024) + "K");
 }
        private void MemoryManager_AppMemoryUsageLimitChanging(object sender, AppMemoryUsageLimitChangingEventArgs e)
        {
            ShowToast("Memory usage limit changing from "
                      + (e.OldLimit / 1024) + "K to "
                      + (e.NewLimit / 1024) + "K");

            if (MemoryManager.AppMemoryUsage >= e.NewLimit)
            {
                ReduceMemoryUsage(e.NewLimit);
            }
        }
Beispiel #8
0
        /// <summary>
        /// Handles application memory limit changes.
        /// </summary>
        /// <param name="e">Instance of <see cref="AppMemoryUsageLimitChangingEventArgs"/>.</param>
        private void OnAppMemroyUsageLimitChanging(object sender, AppMemoryUsageLimitChangingEventArgs e)
        {
            if (MemoryManager.AppMemoryUsage >= e.NewLimit)
            {
                var fields = new LoggingFields();
                fields.AddUInt64("CurrentUsage", MemoryManager.AppMemoryUsage);
                fields.AddUInt64("NewLimit", e.NewLimit);
                TelemetryHelper.LogEventWithParams("MemUsageChanging", fields);

                ReduceMemoryUsage();
            }
        }
Beispiel #9
0
 private void OnMemoryLimitChanged(object sender, AppMemoryUsageLimitChangingEventArgs e)
 {
     System.Diagnostics.Debug.WriteLine("MemoryLimitChanged");
     if (e.NewLimit - e.OldLimit < 0)
     {
         if (AppResources.MainUpContentFrame.Content.GetType().GetTypeInfo().Name == typeof(FM_SongBoardPage).Name)
         {
             _isMusicBoardBeShutDown = true;  // FIRE MUSIC BOARD
             (AppResources.MainUpContentFrame.Content as FM_SongBoardPage).PageSlideOutStart(UWPStates.VisibleWidth > AppResources.FormatNumber ? false : true);
         }
     }
 }
Beispiel #10
0
        /// <summary>
        /// Raised when the memory limit for the app is changing, such as when the app
        /// enters the background.
        /// </summary>
        /// <remarks>
        /// If the app is using more than the new limit, it must reduce memory within 2 seconds
        /// on some platforms in order to avoid being suspended or terminated.
        ///
        /// While some platforms will allow the application
        /// to continue running over the limit, reducing usage in the time
        /// allotted will enable the best experience across the broadest range of devices.
        /// </remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MemoryManager_AppMemoryUsageLimitChanging(object sender, AppMemoryUsageLimitChangingEventArgs e)
        {
            Debug.WriteLine("Memory usage limit changing from "
                            + (e.OldLimit / 1024) + "K to "
                            + (e.NewLimit / 1024) + "K");

            // If app memory usage is over the limit about to be enforced,
            // then reduce usage within 2 seconds to avoid suspending.
            if (MemoryManager.AppMemoryUsage >= e.NewLimit)
            {
                ReduceMemoryUsage(e.NewLimit);
            }
        }
Beispiel #11
0
        /// <summary>
        ///     Raised when the memory limit for the app is changing, such as when the app
        ///     enters the background.
        /// </summary>
        /// <remarks>
        ///     If the app is using more than the new limit, it must reduce memory within 2 seconds
        ///     on some platforms in order to avoid being suspended or terminated.
        ///     While some platforms will allow the application
        ///     to continue running over the limit, reducing usage in the time
        ///     allotted will enable the best experience across the broadest range of devices.
        /// </remarks>
        private async void MemoryManager_AppMemoryUsageLimitChanging(object sender, AppMemoryUsageLimitChangingEventArgs e)
        {
            // If app memory usage is over the limit, reduce usage within 2 seconds
            // so that the system does not suspend the app
            if (MemoryManager.AppMemoryUsage >= e.NewLimit)
            {
                await ReduceMemoryUsageAsync();
            }

            // Send hit
            TelemetryService.Instance.TrackEvent("Reducing Memory Usage", new Dictionary <string, string>
            {
                { "NewLimit", e.NewLimit / 1024 / 1024 + "M" },
                { "OldLimit", e.OldLimit / 1024 / 1024 + "M" },
                { "CurrentUsage", MemoryManager.AppMemoryUsage / 1024 / 1024 + "M" }
            });
        }
Beispiel #12
0
        /// <summary>
        ///     Raised when the memory limit for the app is changing, such as when the app
        ///     enters the background.
        /// </summary>
        /// <remarks>
        ///     If the app is using more than the new limit, it must reduce memory within 2 seconds
        ///     on some platforms in order to avoid being suspended or terminated.
        ///     While some platforms will allow the application
        ///     to continue running over the limit, reducing usage in the time
        ///     allotted will enable the best experience across the broadest range of devices.
        /// </remarks>
        private void MemoryManager_AppMemoryUsageLimitChanging(object sender, AppMemoryUsageLimitChangingEventArgs e)
        {
            // If app memory usage is over the limit, reduce usage within 2 seconds
            // so that the system does not suspend the app
            if (MemoryManager.AppMemoryUsage < e.NewLimit)
            {
                return;
            }

            // Send hit
            TelemetryService.Current.TrackEvent("Reducing Memory Usage", new Dictionary <string, string>
            {
                { "method", "MemoryManager_AppMemoryUsageLimitChanging" },
                { "new_limit", e.NewLimit.ToString() },
                { "old_limit", e.OldLimit.ToString() },
                { "current_usage", MemoryManager.AppMemoryUsage.ToString() },
                { "memory_usage_level", MemoryManager.AppMemoryUsageLevel.ToString() }
            });

            // Reduce the memory usage
            ReduceMemoryUsage();
        }
Beispiel #13
0
 private static void MemoryManager_AppMemoryUsageLimitChanging(object sender, AppMemoryUsageLimitChangingEventArgs e)
 {
     SendToast(string.Format(CultureInfo.CurrentCulture, "old={0}MB, new={1}MB, cur={2}MB",
                             Math.Ceiling((double)e.OldLimit / MB), Math.Ceiling((double)e.NewLimit / MB), Math.Ceiling((double)MemoryManager.AppMemoryUsageLimit / MB)));
 }
Beispiel #14
0
 private void OnMemoryUsageLimitChanging(object sender, AppMemoryUsageLimitChangingEventArgs e)
 {
     UpdateMemoryData();
 }
Beispiel #15
0
 private void MemoryManager_AppMemoryUsageLimitChanging(object sender, AppMemoryUsageLimitChangingEventArgs e)
 => MemoryManager_AppMemoryUsageLimitChangingAsync(sender, e).FireAndForgetSafeAsync();
        /// <summary>
        /// Raised when the memory limit for the app is changing, such as when the app
        /// enters the background.
        /// </summary>
        /// <remarks>
        /// If the app is using more than the new limit, it must reduce memory within 2 seconds
        /// on some platforms in order to avoid being suspended or terminated.
        /// 
        /// While some platforms will allow the application
        /// to continue running over the limit, reducing usage in the time
        /// allotted will enable the best experience across the broadest range of devices.
        /// </remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MemoryManager_AppMemoryUsageLimitChanging(object sender, AppMemoryUsageLimitChangingEventArgs e)
        {
            Debug.WriteLine("Memory usage limit changing from "
                + (e.OldLimit / 1024) + "K to "
                + (e.NewLimit / 1024) + "K");

            // If app memory usage is over the limit about to be enforced,
            // then reduce usage within 2 seconds to avoid suspending.
            if (MemoryManager.AppMemoryUsage >= e.NewLimit)
            {
                ReduceMemoryUsage(e.NewLimit);
            }
        }