windows-phone-8isolatedstoragedynamic-memory-allocationisolatedstoragefile

Windows Phone IsolatedStorageSettings: capacity and dynamic allocation


I am going to save enough big amounts of data in my WP8 app using the handy IsolatedStorageSettings dictionary. However, the first question that arises is how big is it?

Second, in the documentation for the IsolatedStorageSettings.Save method we can find this:

If more space is required, use the IsolatedStorageFile.IncreaseQuotaTo method to request more storage space from the host.

Can we estimate the amount of required memory and increase the room for IsolatedStorageSettings accordingly? What if we need to do that dynamically, as the user is entering new portions of data to store persistently? Or, maybe, we need to use another technique for that (though I would like to stay with the handy IsolatedStorageSettings class)?


Solution

  • I have found the answer to the first part of my question in this article: How to find out the Space in isolated storage in Windows Phone?. Here is the code to get the required value on a particular device with some enhancements:

    long availablespace, Quota;
    using (var store = IsolatedStorageFile.GetUserStoreForApplication())
    {
       availablespace = store.AvailableFreeSpace ;
       Quota = store.Quota ;
    }
    
    MessageBox.Show("Available : " + availablespace.ToString("##,#") + "\nQuota : " + Quota.ToString("##,#));
    

    The 512Mb WP8 emulator gave me the following values for a minimal app with few strings saved in IsolatedStorageSettings:

    Available space in WP8 emulator

    Lumia 920 reports even a much bigger value - about 20Gb, which gladdens my heart. Such a big value (which, I think, depends on the whole available memory in the device) will allow me to use the IsolatedStorageSettings object for huge amounts of data.

    As for a method one can use to estimate the amount of data, I guess, this can be done only experimentally. For instance, when I added some strings to my IsolatedStorageSettings, the available space was reduced by 4Kb. However, adding the same portion of data again did not show any new memory allocation. As I can see, it is allocated by blocks of 4Kb.