mercredi 6 avril 2016

Turn off the WAL file mode in RestKit Swift

What is the magic combination of options to send to the sqlite to completely turn off journaling.

I have an initialization on install that brings down a lot of data. I don’t need journaling at this point and it balloons the memory storage upon install to over 500MB!

I have tried:

var options = Dictionary<NSObject, AnyObject>()
options[NSMigratePersistentStoresAutomaticallyOption] = true
options[NSInferMappingModelAutomaticallyOption] = true
options[NSSQLitePragmasOption] = ["journal_mode" : "TRUNCATE”]

or

options[NSSQLitePragmasOption] = ["journal_mode" : “OFF"]

or

options[NSSQLitePragmasOption] = ["journal_mode" : “DELETE”]

and

options[NSSQLiteManualVacuumOption] = true

even

options[NSSQLitePragmasOption] = ["journal_size_limit" : "20000”]

by :

do {
                    _ = try
                        self.managedObjectStore!.addSQLitePersistentStoreAtPath(storePath, fromSeedDatabaseAtPath: nil, withConfiguration: nil, options: options)
                } catch let error as NSError {
                    print("fail to add persistent store")
                    print(error)
                }

Nothing seems to allow me to turn this off completely. The WAL file always grows.

Aucun commentaire:

Enregistrer un commentaire