realm / realm-swift

Realm is a mobile database: a replacement for Core Data & SQLite
https://realm.io
Apache License 2.0
16.31k stars 2.14k forks source link

Crash on Notification Service Extension (RESOURCE_TYPE_MEMORY) #8606

Closed devssun closed 4 months ago

devssun commented 4 months ago

How frequently does the bug occur?

Always

Description

My Test Information iPhone 11, iOS 17.5.1

In our application, we save push information at notification service extension(NSE). I made project using Tuist. After apply Tuist, RealmSwift occured error when I called tryRealm() from NSE.

the error is Thread 2: EXC_RESOURCE (RESOURCE_TYPE_MEMORY: high watermark memory limit exceeded) (limit=24 MB) 스크린샷 2024-05-27 오후 5 55 57

stacktrace 스크린샷 2024-05-27 오후 5 56 02

I don't understand what happened. please help me.

Stacktrace & log output

Thread 2 Queue : com.apple.NSXPCConnection.user.endpoint (serial)
#5  0x0000000107a8b07c in +[RLMSchema sharedSchema] at /Library/Developer/Xcode/DerivedData/efygztealpifkhargabzepbdapti/SourcePackages/checkouts/realm-cocoa/Realm/RLMSchema.mm:262
#6  0x0000000107a64b28 in +[RLMRealm realmWithConfiguration:queue:error:] at /Library/Developer/Xcode/DerivedData/efygztealpifkhargabzepbdapti/SourcePackages/checkouts/realm-cocoa/Realm/RLMRealm.mm:465
#8  0x0000000107b2a3c4 in Realm.init(configuration:queue:) at /Library/Developer/Xcode/DerivedData/efygztealpifkhargabzepbdapti/SourcePackages/checkouts/realm-cocoa/RealmSwift/Realm.swift:92
#9  0x0000000107b2a600 in Realm.init(fileURL:) at /Library/Developer/Xcode/DerivedData/efygztealpifkhargabzepbdapti/SourcePackages/checkouts/realm-cocoa/RealmSwift/Realm.swift:106

---
Thread 2: EXC_RESOURCE (RESOURCE_TYPE_MEMORY: high watermark memory limit exceeded) (limit=24 MB)

Can you reproduce the bug?

Always

Reproduction Steps

No response

Version

10.7.4

What Atlas Services are you using?

Local Database only

Are you using encryption?

Yes

Platform OS and version(s)

iOS 17.5.1

Build environment

Xcode version: 15.2 Dependency manager and version: SPM

sync-by-unito[bot] commented 4 months ago

➤ PM Bot commented:

Jira ticket: RCOCOA-2372

nirinchev commented 4 months ago

Can you try to explicitly specify the objectTypes in your realm config? That way you can avoid the costly reflection that's needed to build the default schema.

devssun commented 4 months ago

I already defined. This error does not occur in projects where Tuist is not applied. Could settings in the build settings possibly affect this?

public class History: Object {
    @objc public dynamic var _id = ObjectId.generate()
    @objc public dynamic var id: String?
    @objc public dynamic var date: Date = Date()
    @objc public dynamic var read: Bool = false
    @objc public dynamic var dataString: String?
}
nirinchev commented 4 months ago

What do you mean by "I already defined"? The stacktrace seems to indicate that no objectTypes was specified on the realm configuration, which is why we're trying to use reflection to discover the default schema.

devssun commented 4 months ago

oops I'm sorry. I misunderstand and fix this issue. thank you.