realm-java icon indicating copy to clipboard operation
realm-java copied to clipboard

SIGSEGV when using Realm to store heavy data on a thread

Open Dexteroo7 opened this issue 11 years ago • 6 comments

Hello, I encountered : A/libc﹕ Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), this error when I tried to store a complex RealmObject on a thread. I then tried storing a very simple test object and it worked fine. Actully this error does not occur always. Most of the times when I finally finish committing my transaction, the auto-refresh of my realListener does not get called. In fact after running this operation none of the real listeners work no matter what.

My runnable that stores results : private final Runnable findAndAddFriends = new Runnable() { . . final List received = getUsers(0); //getUsers runs an appengine endpoint to retreive //a list of users. . . Realm realm = Realm.getInstance(getActivity()); // my local realm for the thread for (ReachFriends friend : received) { realm.beginTransaction(); Log.i("Ayush", "Friends found !"); //Update friendDatabase //boiler-plate code to generate and store my RealmObject, no threads are spawned in //this MiscUtils.getInstance().transferFriends(friend, realm); realm.commitTransaction(); } realm.close;

} // end of runnable

if instead of running the above operation I create and store a simple object everything runs fine and even my listeners are triggered.

My RealmObject that gives trouble has : 5 strings 5 longs 4 realmLists of realmObjects, these realm objects have 3 strings and a realList of a realmObject which has 9 strings.

I finally gave up and ran the realm part of the code on UI thread (onPostExecute) and everything worked fine. This is weird.

Dexteroo7 avatar Jan 08 '15 19:01 Dexteroo7

Im sorry its mostly that SIGSEGV error, not the other way around

Dexteroo7 avatar Jan 08 '15 20:01 Dexteroo7

Hello and thanks for the report!

Is the result the same if you make one big transaction (outside the for loop) instead of many small ones? It's surely more efficient since opening and closing write transactions has of course an overhead.

emanuelez avatar Jan 08 '15 20:01 emanuelez

Yes, I actully did that because I thought memory was being over used due do holding an un-commited transaction (desperate attempt). Its same both ways. UPDATE : doing my opeartion on an IntentService works perfectly fine

Dexteroo7 avatar Jan 08 '15 20:01 Dexteroo7

That sounds odd. Is there any way for you to share your code, even in a private way? That would speed up the investigation considerably of course.

emanuelez avatar Jan 08 '15 21:01 emanuelez

Ok i will try to port this into a sample application. Meanwhile, I ran a simple test.

@Override protected List doInBackground(Void... voids) {

Realm realm = Realm.getInstance(getActivity()); realm.beginTransaction();for(int i=0; i < 100; i++) { RealmTest realmTest = realm.createObject(RealmTest.class); realmTest.setHelp("GGGG"); } realm.commitTransaction(); realm.close(); } // end of doInBackground

This did not call my RealmChangeListeners. But if I iterate 10 times it does. The bound seems to be 70.

Dexteroo7 avatar Jan 09 '15 12:01 Dexteroo7

Sorry for the trouble. I made a new application with just the basic functionality of storing my data and displaying it in a list. It works perfectly fine. Everything. I must have messed up the integration in my main app. Closing the issue.

Dexteroo7 avatar Jan 09 '15 17:01 Dexteroo7