Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AsyncStorage Size in the Docs #3387

Closed
ryanmcdermott opened this issue Oct 13, 2015 · 20 comments
Closed

AsyncStorage Size in the Docs #3387

ryanmcdermott opened this issue Oct 13, 2015 · 20 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@ryanmcdermott
Copy link

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

@brentvatne
Copy link
Collaborator

@ryanmcdermott - PR welcome!

@ryanmcdermott
Copy link
Author

@brentvatne Would love to! Do you know if AsyncStorage lacks a storage cap in Android as well?

@brentvatne
Copy link
Collaborator

@ryanmcdermott - not sure actually, cc @kmagiera

@kmagiera
Copy link
Contributor

I believe @andreicoman11 has been changing this recently

@andreicoman11
Copy link
Contributor

On android we set a limit of 6mb.

@ide
Copy link
Contributor

ide commented Oct 14, 2015

Any reason not to set it to something like 100-500MB? Micro SD cards these days are easily 16-64GB.

@cosmith
Copy link
Contributor

cosmith commented Oct 14, 2015

+1 for a bigger default than 6MB

@andreicoman11
Copy link
Contributor

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
Copy link

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
Copy link

Could we have bigger size of async storage? Or at least make it configurable? 6mb is kind of nothing for modern phones.

@andreicoman11
Copy link
Contributor

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
Copy link
Contributor

kapv89 commented Apr 2, 2016

@andreicoman11 can you please give some advice as to where should I call setMaximumSize in a project?

@sfrdmn
Copy link

sfrdmn commented 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
Copy link

sfrdmn commented 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 Activity

Ref: https://github.com/facebook/react-native/blob/0.33-stable/ReactAndroid/src/main/java/com/facebook/react/modules/storage/ReactDatabaseSupplier.java#L55

ericpalakovichcarr added a commit to ericpalakovichcarr/react-native that referenced this issue Dec 28, 2016
Currently, there's no documentation on the default 6MB limit on Android for `AsyncStorage`. This pull request adds documentation for iOS and Android size limits, as well as example code to changing the default size limit on Android.

This pull request should properly resolve this issue: facebook#3387 (comment)
@agrass
Copy link

agrass commented May 18, 2017

Hi! I changed the setMaximumSize but still having problems. I get this error: Couldn't read row 0, col 0 from CursorWindow

@jslok
Copy link

jslok commented Nov 5, 2017

@agrass Were you ever able to solve the issue? I have the same error.

@agrass
Copy link

agrass commented Nov 17, 2017

@andreicoman11 @brentvatne Why is wrong to use more than 6mb with AsyncStorage? You mean more than 6mb in one key/value element right? The whole key/values of AsyncStorage together could be greater than that size?

Anyone with another solution? because store the data on the disk is a little slow if you need to persist frequently.

@carlosscheffer
Copy link

@agrass Did you find out something about the limit? Is it for each key or for all?

@ikishanoza
Copy link

Hi set ReactDatabaseSupplier.getInstance(getApplicationContext()).setMaximumSize(600L * 1024L * 1024L);
In MainApplication.java I successfully ride of max size warning but when I get data I got same warning as @agrass and can't get tha data back( I am storing image uri in storage)

can anyone help me ?

@agrass
Copy link

agrass commented Jun 27, 2018

@carlosscheffer @KishanIos007 I think that the best solution right now is just to change the code to store less data in one key of AsyncStorage, and instead of that store in different keys/values of AsyncStorage or in the disk.

@facebook facebook locked as resolved and limited conversation to collaborators Jul 21, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests