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

Memory issue in realm

Open demonar opened this issue 11 years ago • 8 comments

got this issue from my bug tracker:

io.realm.internal.OutOfMemoryErrorstd::bad_alloc in io_realm_internal_Row.cpp line 221

does this give you enough information?

demonar avatar Dec 17 '14 23:12 demonar

Can you provide us with the Android log too? And maybe the Java source code where the exception is thrown.

One reason for this issue can be that your file system hasn't any space left. Can you check that?

kneth avatar Dec 18 '14 08:12 kneth

i'll try to capture more data on the issue

demonar avatar Dec 18 '14 22:12 demonar

This happened to me when not doing transactions properly/not writing in a transaction and then trying to read it.

dotgc avatar Dec 19 '14 02:12 dotgc

@ImGauravC Do you mean something like:

realm.beginTransaction();
obj = realm.createObject(clazz);
realm.commitTransaction();
obj.setFoo("Bar");

kneth avatar Dec 19 '14 09:12 kneth

yes, i think i could find the issue, one of my colleagues was doing that, there should be an exception thrown for this that explains it.

demonar avatar Dec 19 '14 14:12 demonar

When I run the code above I get the expected exception: " java.lang.IllegalStateException: Mutable method call during read transaction."

kneth avatar Dec 19 '14 14:12 kneth

well, i think the issue was that the code was something like:

RealmObject ro = new RealmObject();

some setters.

i found this and replaced with the right

realm.beginTransaction(); obj = realm.createObject(clazz); realm.commitTransaction();

and it disappeared.

demonar avatar Dec 19 '14 15:12 demonar

Ah, I understand. We don't support standalone objects, and RealmObject cannot be used directly but only be used to extend into model classes (this will trigger the annotation processor).

We should probably make it more clear in the documentation and not only "hide" it in http://realm.io/docs/java/0.75.0/api/.

kneth avatar Dec 19 '14 15:12 kneth