clear large profile cache

This commit is contained in:
Milos Kozak 2021-10-17 18:03:55 +02:00
parent e01f6f6cb0
commit a0bc179aea

View file

@ -94,6 +94,11 @@ class ProfileFunctionImplementation @Inject constructor(
@Synchronized @Synchronized
override fun getProfile(time: Long): Profile? { override fun getProfile(time: Long): Profile? {
// Clear cache after longer use
if (cache.size() > 30000) {
cache.clear()
aapsLogger.debug("Profile cache cleared")
}
val rounded = time - time % 1000 val rounded = time - time % 1000
val cached = cache[rounded] val cached = cache[rounded]
if (cached != null) { if (cached != null) {