Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove static view caching to improve memory management #548

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions ListableUI/Sources/Layout/ListLayout/ListLayout+Layout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import UIKit

extension ListProperties {

private static let headerFooterMeasurementCache = ReusableViewCache()
private static let itemMeasurementCache = ReusableViewCache()

/// **Note**: For testing or measuring content sizes only.
///
/// Uses the properties from the list properties to create a `PresentationState`
Expand All @@ -37,8 +34,8 @@ extension ListProperties {
}
}(),
environment: self.environment,
itemMeasurementCache: Self.itemMeasurementCache,
headerFooterMeasurementCache: Self.headerFooterMeasurementCache
itemMeasurementCache: ReusableViewCache(),
headerFooterMeasurementCache: ReusableViewCache()
)

/// 2) Create the layout used to measure the content.
Expand Down
5 changes: 1 addition & 4 deletions ListableUI/Sources/ListView/ListView+ContentSize.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ extension ListView
//
// MARK: Measuring Lists
//

static let headerFooterMeasurementCache = ReusableViewCache()
static let itemMeasurementCache = ReusableViewCache()


public static let defaultContentSizeItemLimit = 50

///
Expand Down
7 changes: 1 addition & 6 deletions ListableUI/Sources/ListView/ListView.Delegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ extension ListView
unowned var view : ListView!
unowned var presentationState : PresentationState!
unowned var layoutManager : LayoutManager!

private let itemMeasurementCache = ReusableViewCache()
private let headerFooterMeasurementCache = ReusableViewCache()

private let headerFooterViewCache = ReusableViewCache()


// MARK: UICollectionViewDelegate

func collectionView(_ collectionView: UICollectionView, shouldHighlightItemAt indexPath: IndexPath) -> Bool
Expand Down
Loading