Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RLMException - 'Binary too big'

Tags:

realm

I am trying to save a Realm Object (Event) to the realm database, yet when I attempt to it crashes stating that:

Terminating app due to uncaught exception 'RLMException', reason: 'Binary too big'
*** First throw call stack:
(0x185c08f5c 0x19a70ff80 0x1004d0d40 0x1004cf850 0x1004fc718 0x1004d1514 0x1004cfc0c 0x1004fc718 0x100960634 0x100047584 0x100962888 0x1005b9244 0x100960100 0x100043750 0x1000438cc 0x18b1963c8 0x18b196344 0x18b17ec6c 0x18b195c5c 0x18b150bdc 0x18b18f548 0x18b18eaac 0x18b15fa10 0x18b15defc 0x185bc05a4 0x185bc0038 0x185bbdd38 0x185aecdc0 0x190c40088 0x18b1c6f44 0x10003cee8 0x19af3a8b8)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

I try to save it like this:

try! realm.write{
                self.realm.add(self.theEvent)
            }

My Event object looks something along these lines:

class Event: Object {
dynamic var title: String = ""
dynamic var image: NSData = NSData()
let items = List<Item>()
}

Where an Item is basically just another object that stores one photo.

I am confused as to why attempting to save just 2 photos (1 item in the list plus the image for the event) results in realm claiming it is over 16MB.

Thank you!

like image 612
alex1511 Avatar asked Oct 20 '15 22:10

alex1511


1 Answers

Depending on how your serializing the image data (for example if it's a lossless bitmap), it's quite possible that this data exceed 16MB, which as you've stated is Realm's maximum supported size for binary properties.

When you invoke NSData.length, how large does it say your data is?

like image 81
jpsim Avatar answered Oct 19 '22 22:10

jpsim