Userdefaults performance validation

I have tried to insert 1L key-values into the user defaults. It is working fine until 50k key-values. After some time, am getting

Not updating lastKnownShmemState in CFPrefsPlistSource<0x2825b0c60> (Domain: peformance_validator, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: No)

also, key-values are not updating in the plist as well. peformance_validator is my user defaults group name.

How can I solve this ?

Replies

How can I solve this ?

Find some other way to store this data, e.g. in the filesystem.

  • I am trying to do some performance analysis on this. Want to know threshold limits for the user defaults.

Add a Comment

UserDefaults is intended to store small preferences. I’m not sure why you’re trying to run performance analysis on it, but your test limits are far beyond the expected use case.

If you need to store 50 thousand records, or even 1 thousand records, user defaults is not the API to use. There are plenty of other options, including the file system, Core Data, and Swift Data.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"