How does the size of a realm-file develop?

后端 未结 1 1752
难免孤独
难免孤独 2021-01-07 01:04

How does the size of a realm-file develop ?

To start with: I have a realm-file with several properties and one of them being an array of 860 entries and each array-e

1条回答
  •  有刺的猬
    2021-01-07 01:24

    It's pretty well observed. :-) The Realm file starts out at about 4k and will double in size once it runs out of free space. It keeps doubling until 128M and then adds constantly 128M thereafter.

    The reason to double the file and not just grow linearly is only due to performance. It's a common algorithm for dynamic data structures to just keep doubling.

    You can use the methods available as seen below to write a compacted copy removing all free space in the file. This can be useful if you don't add new data anymore, want to ship a static database or want to send the file over the network.

    • Realm.writeCopyToURL(_:encryptionKey:) in Swift
    • -[RLMRealm writeCopyToURL:encryptionKey:error:] in Objective-C
    • Realm.writeCopyTo() in Java

    Those thresholds and algorithm mentioned are the current ones, and may change in future versions though.

    Hope this clarifies?

    0 讨论(0)
提交回复
热议问题