{"action":"created","issue":{"url":"https://api.github.com/repos/realm/realm-cocoa/issues/4837","repository_url":"https://api.github.com/repos/realm/realm-cocoa","labels_url":"https://api.github.com/repos/realm/realm-cocoa/issues/4837/labels{/name}","comments_url":"https://api.github.com/repos/realm/realm-cocoa/issues/4837/comments","events_url":"https://api.github.com/repos/realm/realm-cocoa/issues/4837/events","html_url":"https://github.com/realm/realm-cocoa/issues/4837","id":220289860,"number":4837,"title":"[Swift 2.5.1] Realm DB size grows to over 1 GB and causing app crash","user":{"login":"shuhaodo","id":1503837,"avatar_url":"https://avatars2.githubusercontent.com/u/1503837?v=3","gravatar_id":"","url":"https://api.github.com/users/shuhaodo","html_url":"https://github.com/shuhaodo","followers_url":"https://api.github.com/users/shuhaodo/followers","following_url":"https://api.github.com/users/shuhaodo/following{/other_user}","gists_url":"https://api.github.com/users/shuhaodo/gists{/gist_id}","starred_url":"https://api.github.com/users/shuhaodo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shuhaodo/subscriptions","organizations_url":"https://api.github.com/users/shuhaodo/orgs","repos_url":"https://api.github.com/users/shuhaodo/repos","events_url":"https://api.github.com/users/shuhaodo/events{/privacy}","received_events_url":"https://api.github.com/users/shuhaodo/received_events","type":"User","site_admin":false},"labels":[{"id":3303146,"url":"https://api.github.com/repos/realm/realm-cocoa/labels/T:Help","name":"T:Help","color":"cc317c","default":false}],"state":"open","locked":false,"assignee":{"login":"bdash","id":54825,"avatar_url":"https://avatars0.githubusercontent.com/u/54825?v=3","gravatar_id":"","url":"https://api.github.com/users/bdash","html_url":"https://github.com/bdash","followers_url":"https://api.github.com/users/bdash/followers","following_url":"https://api.github.com/users/bdash/following{/other_user}","gists_url":"https://api.github.com/users/bdash/gists{/gist_id}","starred_url":"https://api.github.com/users/bdash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bdash/subscriptions","organizations_url":"https://api.github.com/users/bdash/orgs","repos_url":"https://api.github.com/users/bdash/repos","events_url":"https://api.github.com/users/bdash/events{/privacy}","received_events_url":"https://api.github.com/users/bdash/received_events","type":"User","site_admin":false},"assignees":[{"login":"bdash","id":54825,"avatar_url":"https://avatars0.githubusercontent.com/u/54825?v=3","gravatar_id":"","url":"https://api.github.com/users/bdash","html_url":"https://github.com/bdash","followers_url":"https://api.github.com/users/bdash/followers","following_url":"https://api.github.com/users/bdash/following{/other_user}","gists_url":"https://api.github.com/users/bdash/gists{/gist_id}","starred_url":"https://api.github.com/users/bdash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bdash/subscriptions","organizations_url":"https://api.github.com/users/bdash/orgs","repos_url":"https://api.github.com/users/bdash/repos","events_url":"https://api.github.com/users/bdash/events{/privacy}","received_events_url":"https://api.github.com/users/bdash/received_events","type":"User","site_admin":false}],"milestone":null,"comments":22,"created_at":"2017-04-07T18:17:03Z","updated_at":"2017-04-08T00:39:56Z","closed_at":null,"body":"## Goals\r\n\r\nDB file stays at a reasonable level\r\n\r\n## Expected Results\r\n\r\nDB file size is at 10MB\r\n\r\n## Actual Results\r\n\r\nDB file size is at 1.88 GB and causes app crash\r\n\r\n## Steps to Reproduce\r\n\r\nI have got some additional info:\r\n\r\n1. It still happened in v2.5.1\r\n2. It happened to tens of thousands of users, causing a significant drop of DAU, and we can reproduce it easily too.\r\n3. The app uses realm in multiple threads on the main thread and background threads through GCD. We don't use NSOperationQueue.\r\n4. Write happens both on main thread and bg thread, but mainly on bg thread (>98% of the writes)\r\n5. Read happens on both main and bg threads too, about 40% & 60%, it's hard to put an accurate number as we do not limit read access to certain threads.\r\n6. We have app extensions so realm file is in shared group. But the extensions are rarely used.\r\n7. Write to realm very frequently. We are an email app, lots of I/O happen when app comes to foreground.\r\n8. Yes, multiple threads are writing simultaneously.\r\n\r\nThe latest instance happened this morning. When I checked the DB size last night, it was 10MB; This morning it was 1.88GB when it's opened. As an email app, it would fetch email in the background mode when push notifications came in. There were about 5 notifications came in last night.\r\n\r\n## Code Sample\r\n\r\nNo code sample was provided.\r\n\r\n## Version of Realm and Tooling\r\n\r\n- Realm framework version: 2.5.1\r\n- Xcode version: 8.3\r\n- iOS/OSX version: 10.3"},"comment":{"url":"https://api.github.com/repos/realm/realm-cocoa/issues/comments/292682255","html_url":"https://github.com/realm/realm-cocoa/issues/4837#issuecomment-292682255","issue_url":"https://api.github.com/repos/realm/realm-cocoa/issues/4837","id":292682255,"user":{"login":"shuhaodo","id":1503837,"avatar_url":"https://avatars2.githubusercontent.com/u/1503837?v=3","gravatar_id":"","url":"https://api.github.com/users/shuhaodo","html_url":"https://github.com/shuhaodo","followers_url":"https://api.github.com/users/shuhaodo/followers","following_url":"https://api.github.com/users/shuhaodo/following{/other_user}","gists_url":"https://api.github.com/users/shuhaodo/gists{/gist_id}","starred_url":"https://api.github.com/users/shuhaodo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shuhaodo/subscriptions","organizations_url":"https://api.github.com/users/shuhaodo/orgs","repos_url":"https://api.github.com/users/shuhaodo/repos","events_url":"https://api.github.com/users/shuhaodo/events{/privacy}","received_events_url":"https://api.github.com/users/shuhaodo/received_events","type":"User","site_admin":false},"created_at":"2017-04-08T00:39:56Z","updated_at":"2017-04-08T00:39:56Z","body":"Thanks @bdash, yes, occasionally when dispatch_async to main thread. So calling realm.refresh() every time won't cause stability issue right?\r\n\r\nNow all the GCD queues will run in autorelease pool:\r\n\r\n`dbQueue = dispatch_queue_create(\"com.edo.DB.bg.queue\", dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_CONCURRENT_WITH_AUTORELEASE_POOL, QOS_CLASS_USER_INTERACTIVE, 0));`"}}
{"actor":{"display_login":"shuhaodo"}}