领域文件太大 [英] Realm file size is too large

查看:100
本文介绍了领域文件太大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Realm集成到我的项目中,并注意到一个问题.我看过其他相关文章,但它们是一年多以前的事,已经解决了.

I'm trying to integrate Realm into my project and noticed an issue. I've seen other posts on this, but they were a little over a year ago and have been resolved..

将对象添加到Realm时,事物就是文件.但是,当删除对象时,它们将从数据库中删除,但是文件大小仍然很大.如果在TextEdit中打开领域文件,则可以看到旧记录的原始文本.为什么它们没有被完全删除?

When adding objects to Realm, things are file. But when removing objects, they get removed from the DB, but the file size is still large. If I open the realm file in TextEdit, I can see raw text of old records. Why aren't they getting fully deleted?

看一下这个屏幕截图. Realm DB中的文件为零,但文件大小为23 mb.

Take a look at this screenshot. Zero files in the Realm DB, but the file size is 23 mb.

谢谢.

推荐答案

bcamur感到悲伤,

as bcamur sad,

Realm文件将在磁盘上保持其大小,以有效地重用 未来物体的空间

the Realm file will maintain its size on disk to efficiently reuse that space for future objects

但也有文字

多余的空间最终将在以后的写入中重复使用,或者可能是 压缩-例如通过调用 Realm().writeCopyToPath(_:encryptionKey:).

The extra space will eventually be reused by future writes, or may be compacted — for example by calling Realm().writeCopyToPath(_:encryptionKey:).

致电invalidate告诉Realm您不再需要任何 到目前为止,您已经从Realm中读取的对象,这使我们摆脱了 跟踪这些对象的中间版本.领域将更新 下次访问时将其更新为最新版本

call invalidate to tell Realm that you no longer need any of the objects that you’ve read from the Realm so far, which frees us from tracking intermediate versions of those objects. The Realm will update to the latest version the next time it is accessed

这篇关于领域文件太大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆