1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-17 17:22:54 +08:00
osu-lazer/osu.Game/Overlays/Settings/Sections/DebugSettings/MemorySettings.cs
Dean Herbert 11e07c1137 Add button to compact realm on demand
In general we're doing things correctly so the realm file shouldn't
expand (unless mass deletions are made from it), but this is a nice way
to manually confirm the behaviour.

Sometimes if using realm studio with osu! running, for instance, the
realm file size can blow out of proportion. This will recover from such
cases.

Note that calling `RealmFactory.Compact` itself is not enough, as it
will fail unless all instances of the realm have been closed.
2022-01-12 15:22:36 +09:00

43 lines
1.4 KiB
C#

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Framework.Platform;
using osu.Game.Database;
using osu.Game.Localisation;
namespace osu.Game.Overlays.Settings.Sections.DebugSettings
{
public class MemorySettings : SettingsSubsection
{
protected override LocalisableString Header => DebugSettingsStrings.MemoryHeader;
[BackgroundDependencyLoader]
private void load(FrameworkDebugConfigManager config, GameHost host, RealmContextFactory realmFactory)
{
Children = new Drawable[]
{
new SettingsButton
{
Text = DebugSettingsStrings.ClearAllCaches,
Action = host.Collect
},
new SettingsButton
{
Text = DebugSettingsStrings.CompactRealm,
Action = () =>
{
// Blocking operations implicitly causes a Compact().
using (realmFactory.BlockAllOperations())
{
}
}
},
};
}
}
}