fix: reduce ram usage#1446
Open
sesky4 wants to merge 2 commits into
Open
Conversation
Collaborator
Your fix just effectively sets the history limit to 50. How are you handling if someone wants to search for content older than the last 50 entries?
Do you have data that
Already handled in #1441. Note that while this improves performance when copying I found to real effect of it on memory usage.
Thumbnails are generated as soon as an item is displayed. Not on view creation. |
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.
Summary
Hi, I found Maccy uses ~2.4 GB of memory at startup on my machine with a large clipboard history (hundreds of items with images/RTF blobs). Others have reported the same issue (#1240 #1294 #1129 #1088). This PR reduces startup memory.
Issues
History.load()uses aFetchDescriptor<HistoryItem>()with nofetchLimit, eagerly loading every row and allcontentsrelationships into memory.HistoryItemContent.valuestores image/RTF blobs inline in SQLite, so every fetch hydrates all of them into__DataStorage._bytes.findSimilarItem()does another unboundedFetchDescriptor<HistoryItem>()per clipboard change for dedup.ensureThumbnailImage()decodes full-resolutionNSImagefor every row during view construction, even when the popup isn't visible.Changes
HistoryItemContent.value: add@Attribute(.externalStorage)so blobs are stored out-of-line and loaded lazily.History.load(): separate pinned (unlimited) and unpinned (fetchLimit = min(size, 50)) fetches, each sorted by the user's sort order.findSimilarItem(): search the in-memoryallarray instead of doing a full-table fetch.HistoryItemView: gateensureThumbnailImage()onscenePhase == .active.Testing
macOS 26.5.1, 1,140 items in DB (SQLite file ~2.8 GB).
Filling 999 slots with fresh text copies kept memory stable at ~59 MB. Pins, search, delete, paste stack all work.
Backward compatibility
@Attribute(.externalStorage)triggers a transparent Core Data migration on first launch. Existing data is preserved — no data loss.