{"action":"created","issue":{"url":"https://api.github.com/repos/realm/realm-java/issues/3909","repository_url":"https://api.github.com/repos/realm/realm-java","labels_url":"https://api.github.com/repos/realm/realm-java/issues/3909/labels{/name}","comments_url":"https://api.github.com/repos/realm/realm-java/issues/3909/comments","events_url":"https://api.github.com/repos/realm/realm-java/issues/3909/events","html_url":"https://github.com/realm/realm-java/issues/3909","id":195538631,"number":3909,"title":"OOM crash with Realm 1.2.0","user":{"login":"stan-ko","id":947359,"avatar_url":"https://avatars.githubusercontent.com/u/947359?v=3","gravatar_id":"","url":"https://api.github.com/users/stan-ko","html_url":"https://github.com/stan-ko","followers_url":"https://api.github.com/users/stan-ko/followers","following_url":"https://api.github.com/users/stan-ko/following{/other_user}","gists_url":"https://api.github.com/users/stan-ko/gists{/gist_id}","starred_url":"https://api.github.com/users/stan-ko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stan-ko/subscriptions","organizations_url":"https://api.github.com/users/stan-ko/orgs","repos_url":"https://api.github.com/users/stan-ko/repos","events_url":"https://api.github.com/users/stan-ko/events{/privacy}","received_events_url":"https://api.github.com/users/stan-ko/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-12-14T14:03:30Z","updated_at":"2016-12-15T11:44:52Z","closed_at":null,"body":"Hi!\r\n\r\nI'm facing OOM crash issue with Realm. My app creates 3-4 instances (one per thread) of Realm during execution. Maybe each created instance ignoring its further close() and stays in RAM and thats why it ends up trying to allocate more than 50 megs of RAM. My whole DB is about 3 Mb (default.realm is 3.75Mb) how comes it want 50 if I'm not using all the data/tables simultaneously? Does every instance allocates RAM for whole DB (16mb in my case) while creates its own heap?\r\n\r\n#### Goal\r\n\r\nUse Realm from different threads simultaneously\r\n\r\n#### Expected Results\r\n\r\nNo OOM\r\n\r\n#### Actual Results\r\n\r\nFatal Exception: io.realm.exceptions.RealmError: Unrecoverable error. mmap() failed: Out of memory size: 50331648 offset: 0 in io_realm_internal_SharedGroup.cpp line 113\r\n       at io.realm.internal.SharedGroup.createNativeWithImplicitTransactions(SharedGroup.java)\r\n       at io.realm.internal.SharedGroup.<init>(SharedGroup.java:64)\r\n       at io.realm.internal.SharedGroupManager.<init>(SharedGroupManager.java:49)\r\n       at io.realm.BaseRealm.<init>(BaseRealm.java:77)\r\n       at io.realm.Realm.<init>(Realm.java:138)\r\n       at io.realm.Realm.createAndValidate(Realm.java:269)\r\n       at io.realm.Realm.createInstance(Realm.java:249)\r\n       at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:114)\r\n       at io.realm.Realm.getInstance(Realm.java:213)\r\n\r\n\r\n#### Version of Realm and tooling\r\nRealm version(s): 1.2.0. Сan't use 2.x since it crashes on Samsung devices (another issue)\r\n\r\nRealm sync feature enabled: no\r\n\r\nAndroid Studio version: 2.2.2\r\n\r\nWhich Android version and device: vary\r\nhttp://prntscr.com/djana1\r\n"},"comment":{"url":"https://api.github.com/repos/realm/realm-java/issues/comments/267308618","html_url":"https://github.com/realm/realm-java/issues/3909#issuecomment-267308618","issue_url":"https://api.github.com/repos/realm/realm-java/issues/3909","id":267308618,"user":{"login":"kneth","id":1225363,"avatar_url":"https://avatars.githubusercontent.com/u/1225363?v=3","gravatar_id":"","url":"https://api.github.com/users/kneth","html_url":"https://github.com/kneth","followers_url":"https://api.github.com/users/kneth/followers","following_url":"https://api.github.com/users/kneth/following{/other_user}","gists_url":"https://api.github.com/users/kneth/gists{/gist_id}","starred_url":"https://api.github.com/users/kneth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kneth/subscriptions","organizations_url":"https://api.github.com/users/kneth/orgs","repos_url":"https://api.github.com/users/kneth/repos","events_url":"https://api.github.com/users/kneth/events{/privacy}","received_events_url":"https://api.github.com/users/kneth/received_events","type":"User","site_admin":false},"created_at":"2016-12-15T11:44:52Z","updated_at":"2016-12-15T11:44:52Z","body":"Instances as such do not require memory. But Realm is a MultiVersion Concurrent Control database which means that each instance will keep a copy/snapshot of the database alive. When an instance is closed (or refreshed = updated to latest version), Realm can reclaim the space. If you don't close a couple of instances, these versions of your database will be kept alive.\r\n\r\nSee also https://realm.io/docs/java/latest/#large-realm-file-size."}}
{"actor":{"display_login":"kneth"}}