Skip to content

Commit

Permalink
mecanism to free cache memory for memory intensive files that don't r…
Browse files Browse the repository at this point in the history
…equire multiple read
  • Loading branch information
roznet committed Feb 22, 2021
1 parent d693f59 commit e93bdf6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Sources/FitFileParser/FitFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,12 @@ public class FitFile {
}
return rv
}

/// Clear all cached value when memory need to be reclaimed. All value will then be recalculated if needed
public func purgeCache() {
for message in self.messages {
message.purgeCache()
}
}

}
5 changes: 5 additions & 0 deletions Sources/FitFileParser/FitMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ public class FitMessage : Codable {
return interp[key]
}

/// Clear all cached value when memory need to be reclaimed. All value will then be recalculated if needed
public func purgeCache() {
self.cacheInterpretation = [:]
}

/// Returns the best swift interpreation of each of the field in the message
/// Some of the interpration is generic or a function of knowledge on the field, for example times or coordinates
/// the returned FitFieldValue
Expand Down

0 comments on commit e93bdf6

Please sign in to comment.