-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Unrecoverable error. mmap() failed: Out of memory #3502
Comments
Did you use I am actually not sure if it's necessary, but I think it might be. Also, query for results inside the transaction when you're on a background thread, and preferably don't execute multiple transactions on the same loop. |
I did not set it explicitly but I think it's default on looper threads. I think I never use more than one transaction... |
Realm instances that are closed should release their versions. The addition of size added by previous versions is not released automatically (only with Meaning your file should not increase so drastically, unless you have many concurrent background threads that continuously create new versions that can never be filled up by future threads. Or if your versions are not released sometimes, in which case you should consider putting |
@leisim The file size will not decrease but freed resources (deleted objects, old versions) will be reused eventually. Unfortunately, Realm doesn't yet support online compaction (compacting open Realms). Can you schedule a restart of the app? If so, you could compact the Realm during restart. |
@kneth OK. I can schedule a restart but of course it is not ideal. The app is used 24/7 by our employees and a restart will disturb their work. Is online compaction a scheduled feature? Is there an issue I can watch? This issue sounds quite similar but it is already closed realm/realm-core#34 |
Oh dear, that's a very old issue and Realm files can easily come larger than 2 GB. Actually, it's more Online compaction isn't currently a scheduled feature as we didn't image that apps with run 24/7. Is it possible for you to share your app with us? By reading the source code, we might be able to give you a suggestion on how to get around it. |
Close due to no response. |
Goal
My app runs in kiosk mode and it can not be restarted for at least a month (This is why I can't use
compactRealm()
). The app syncs about twice per minute with the server on a background thread and the realm database is being accessed every time.It is impossible that I forgot to close a Realm. I tripe checked it. And I used the following Kotlin method to make sure there is no leak.
Actual Results
I still get the same error as in #3050 and I tried running the network access on a looper thread and closing the realm during long running operations. After some time the app has a memory (disk) usage of about 1.8Gb :/ But the stored data should not take more than 50kb.
Steps & Code to Reproduce
Sadly I cannot reproduce the error. Some time the app runs without a problem and without taking more space and after about two weeks the memory usage explodes.
Version of Realm and tooling
Realm version(s): 1.2.0
Android Studio version: 2.2
Which Android version and device: Android 5.1.0, Hardkernel ODROID C2
Is it possible that
Realm
keeps old DB versions after closing the Realm and after shutting down the looper safely?The text was updated successfully, but these errors were encountered: