Turn off the WAL file mode in RestKit Swift

160 views Asked by At

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.

1

There are 1 answers

0
Arun Gupta On

You were almost there just a small correction

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