Skip to content

armgit / Filee

Public Imported from GitHub
0

Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.

Trim with non-compacting collections; trim in the test host again

KnifeLemon1becc9e35477
diff --git a/src/Filee.App/Services/MemoryTrimmer.cs b/src/Filee.App/Services/MemoryTrimmer.cs
index ca435df3..85f94a38 100644
--- a/src/Filee.App/Services/MemoryTrimmer.cs
+++ b/src/Filee.App/Services/MemoryTrimmer.cs
@@ -82,11 +82,12 @@ public sealed class MemoryTrimmer : IDisposable
var watch = Stopwatch.StartNew();
var before = PrivateMegabytes();
EngineCaches.Release();
- // Not Aggressive and no LOH compaction (5-8 MB more would go): both move the large object heap, which native
- // code may hold pointers into, e.g. a rendered frame Skia encodes on the UI thread (it crashed on CI).
- GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, blocking: true, compacting: true);
+ // Without compacting: a compacting collection moves old objects, and native code (the UI's Skia renderer)
+ // can hold pointers into them; the test run crashed in Skia half a minute after such a trim. Garbage is
+ // freed and empty heap regions are decommitted all the same.
+ GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, blocking: true, compacting: false);
GC.WaitForPendingFinalizers();
- GC.Collect();
+ GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, blocking: true, compacting: false);
ProcessMemory.TrimWorkingSet();
log.LogInformation("Trimmed memory: private {Before} MB → {After} MB (managed heap {Heap} MB) in {Elapsed} ms",
before, PrivateMegabytes(), GC.GetTotalMemory(false) / (1024 * 1024), watch.ElapsedMilliseconds);
diff --git a/tests/Filee.App.Tests/TestApp.cs b/tests/Filee.App.Tests/TestApp.cs
index f667c961..dc0a3187 100644
--- a/tests/Filee.App.Tests/TestApp.cs
+++ b/tests/Filee.App.Tests/TestApp.cs
@@ -41,8 +41,6 @@ internal static class TestServices
{
AppHost.Build(DataDirectory);
AppHost.Get<UserDataStore>().Load();
- // DIAGNOSTIC (CI crash in RenderTests): no idle memory trim in the shared test host.
- AppHost.Get<Filee.App.Services.MemoryTrimmer>().Dispose();
AppHost.Get<LocalizationService>().Attach(app);
_initializedFor = app;
}