Core Data sqlite-wal file exploding in size

Is the wal file supposed to fluctuate in size or just keep on growing in size? It seems to be ever-growing.

data.sqlite - 266KB
data.sqlite-shm - 33KB
data.sqlite-wal - 3.3MB

Are there any zombie objects or such causing the file size to keep on growing? How do I debug what's causing the write-ahead-log file to keep growing in size?
3mb isn’t very large. Generally the wal file will checkpoint at a convenient time for the system which may be the next time you open the store.

Are you using query generations? Contexts pinned to a query generation prevent checkpoints until they are advanced to current or deallocated.
You could control the size of WAL file by setting sqlite PRAGMA Options.

Code Block language
NSDictionary * options = @{
NSMigratePersistentStoresAutomaticallyOption:@YES,
NSInferMappingModelAutomaticallyOption:@YES,
NSSQLitePragmasOption:@{ @"journal_mode" : @"WAL", @"journal_size_limit" : @"20000" }
};


In my case it was around 1 gb, because I was inserting blobs at regular intervals 5 seconds, I used journal_mode = Delete and was able to get rid of sqlite-wal file but however I noticed that anything I write to coredata was not synced to cloud and this was the biggest setback for me. So I tried every possible such as writing the blobs to text and syncing it to icloud docs, but this involves lot of manual work because you need to upload the entire blob file rather than just the updated content and eventually this will slow down my app. Finally I realised if I could increase the intervals to 60 seconds the file size reduced to < 100 kb which was ok for me, if the app crashes this piece of data will be lost and hence I introduced userdefaullts as intermediatery handler for the 60 seconds and once its inserted to coredata I would just clear userdefaults for next cycle. This way I brought 1 gb file to <100 kb.

Core Data sqlite-wal file exploding in size
 
 
Q