Repository navigation
Fix container state and memory leaks, and move reports into a service - #5
Merged
armartinez merged 1 commit intoOct 24, 2026
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
For all but trivial fixes, make sure to first create a GitHub issue that concisely describes the bug or desired enhancement as justification for the change. Large PRs with no justifying issue will be closed.
Related Issue
Closes #
Type of Change
Motivation and Context
Starting or stopping several containers at once left their state dots wrong: a row was disabled, but its dot still showed the old state. All container boots and stops shared one lock, so each container waited for the others' stop timeouts before its own state changed.
Memory profiling with
leaks,heapandvmmapfound that closed report and container detail windows were never freed. Retain cycles kept their views alive, with about 160 MB of window graphics. It also found that a container whose start fails kept its virtual machine object, log file handle and IP address until the app quit. The container also couldn't be deleted or started again.Reports were written through
ReportManager, and other managers created aReportManagerof their own to delete reports. That broke the rule that a manager never uses another manager.Description
Container state and concurrency
ContainersServicenow uses a lock for each container instead of one for all of them, so containers start and stop in parallel. The lock still keeps one container's boot, start, stop and delete from overlapping.startProcessanddeletenow use it too. A stop can no longer land between a container's boot and the start of its process. A container that is booting can't be deleted, which would have left its virtual machine running with nothing to stop it.ContainersViewruns its list refreshes one at a time, so an older list can no longer overwrite a newer one.ContainersService structure
ContainersServicenow lives inRuntime/Services/Containers/, split by area into+Lifecycle,+Configuration,+Processes,+Networkingand+Streams.markStopped(id:exitCode:).Memory leaks
dismantleNSView. Each controller is kept in the@Stateof the same view those closures capture.DetailToolbarController's display-mode observation capturesselfweakly..errorAlertholds its window weakly. Holding it strongly kept closed windows alive.Reports
ReportsService: an actor that the runtime creates and owns, like the other services.ReportManagerrecords reports through it.ContainerManager,ImageManagerandVolumeManagerdelete reports through the runtime'sgetReportsService(), not through aReportManagerof their own.ReportManager.remove(_:)is nowdelete(ids:), andentry(for:)is nowget(id:).App
.task(id:)instead of a Combine debounce.containersapp link.Docs
AGENTS.md: updated for the newRuntime/layout, the runtime's service accessors andReportsService.Testing
Added
ReportManagerTestsand a test that deleting a volume deletes its reports, and updatedMockContainerRuntimeto provide aReportsService.Checked with
leaks,heapandvmmapafter opening and closing report and container detail windows several times, starting and stopping containers, and starting a container whose image has no entry point:leaks: 19 leaks before, 0 after.stdio.loghandles left open: 1 before, none after.