Skip to content

AsyncStorage Size in the Docs #3387

Closed
Closed
@ryanmcdermott

Description

@ryanmcdermott

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

Activity

brentvatne

brentvatne commented on Oct 13, 2015

@brentvatne
Collaborator

@ryanmcdermott - PR welcome!

ryanmcdermott

ryanmcdermott commented on Oct 13, 2015

@ryanmcdermott
Author

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

brentvatne

brentvatne commented on Oct 13, 2015

@brentvatne
Collaborator

@ryanmcdermott - not sure actually, cc @kmagiera

kmagiera

kmagiera commented on Oct 13, 2015

@kmagiera
Contributor

I believe @andreicoman11 has been changing this recently

andreicoman11

andreicoman11 commented on Oct 13, 2015

@andreicoman11
Contributor

On android we set a limit of 6mb.

ide

ide commented on Oct 14, 2015

@ide
Contributor

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

cosmith

cosmith commented on Oct 14, 2015

@cosmith
Contributor

+1 for a bigger default than 6MB

andreicoman11

andreicoman11 commented on Oct 14, 2015

@andreicoman11
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

davidLeonardi commented on Feb 2, 2016

@davidLeonardi

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

vmakhaev commented on Feb 24, 2016

@vmakhaev

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

andreicoman11

andreicoman11 commented on Feb 24, 2016

@andreicoman11
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

kapv89 commented on Apr 2, 2016

@kapv89
Contributor

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

sfrdmn

sfrdmn commented on Sep 2, 2016

@sfrdmn

@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

sfrdmn commented on Sep 2, 2016

@sfrdmn

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

12 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @brentvatne@hramos@davidLeonardi@ide@sfrdmn

        Issue actions

          AsyncStorage Size in the Docs · Issue #3387 · facebook/react-native