Closed
Description
Just a quick change that would be great to see in the docs, is to list the size of AsyncStorage. This was answered by @ide in a StackOverflow question: http://stackoverflow.com/questions/32875726/how-large-is-asyncstorage-in-react-native
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
brentvatne commentedon Oct 13, 2015
@ryanmcdermott - PR welcome!
ryanmcdermott commentedon Oct 13, 2015
@brentvatne Would love to! Do you know if AsyncStorage lacks a storage cap in Android as well?
brentvatne commentedon Oct 13, 2015
@ryanmcdermott - not sure actually, cc @kmagiera
kmagiera commentedon Oct 13, 2015
I believe @andreicoman11 has been changing this recently
andreicoman11 commentedon Oct 13, 2015
On android we set a limit of 6mb.
ide commentedon Oct 14, 2015
Any reason not to set it to something like 100-500MB? Micro SD cards these days are easily 16-64GB.
cosmith commentedon Oct 14, 2015
+1 for a bigger default than 6MB
andreicoman11 commentedon Oct 14, 2015
I think android and iOS deal with this differently. On android, cache information should not be stored in databases, but in files in designated cache folders which can then be cleaned up when necessary. Databases should be used to store information that is absolutely necessary for the app, information that cannot be automatically reclaimed by the system.
With that in mind, a database should not need to grow bigger then the limit set right now.
However, since there's no way to use any other caching mechanism from within react native, an intermediate solution would be to make it possible to database size limit configurable.
PS: android devices are much more prone to memory issues than iOS devices. Even with the possibility of extra micro SD cards, many android devices will regularly run into problems with not having enough memory for caching purposes. Apps should be designed in such a way to properly deal with this.
PPS: careful with storing any sort of information on SD cards! Any user data stored on the SD card has to be properly encrypted (our database for example is not encrypted). Otherwise, you can run into privacy violation issues.
davidLeonardi commentedon Feb 2, 2016
I think this is still relevant.
If you give us only 6MB, then i'd somehow like to know how much free space I still have. Nowhere in the API can i find something like that. What will happen when i hit the limit? Will it just throw an error?
vmakhaev commentedon Feb 24, 2016
Could we have bigger size of async storage? Or at least make it configurable? 6mb is kind of nothing for modern phones.
andreicoman11 commentedon Feb 24, 2016
You can set the maximum size of the database via
setMaximumSize
.As mentioned before, careful with doing this. If you need more than 6MB to be stored in the database (not in cache, which is a different issue), then you are most likely doing something wrong.
kapv89 commentedon Apr 2, 2016
@andreicoman11 can you please give some advice as to where should I call
setMaximumSize
in a project?sfrdmn commentedon Sep 2, 2016
@andreicoman11 Why shouldn't apps store more than 6MB in their local databases? Seems true under the assumption of relatively light clients. P2P applications, however, might well expect to save more than 6MB worth of data (as one example)
sfrdmn commentedon Sep 2, 2016
BTW @kapv89, I haven't tried this out, but looks like you can call
ReactDatabaseSupplier.getInstance(getApplicationContext()).setMaximumSize(/*x bytes*/)
in your main ActivityRef: https://github.com/facebook/react-native/blob/0.33-stable/ReactAndroid/src/main/java/com/facebook/react/modules/storage/ReactDatabaseSupplier.java#L55
12 remaining items