Android Question OutOfMemoryError width Object Serializer

Roberto P.

Well-Known Member
Licensed User
Longtime User
Hi All,
I created a system for the exchange of objects (lists) with the server developed with B4j.
If amount of objects bigger than 2mb, you get this error.

B4XSerializator use for data exchange.

Some advice to solve the problem?

thank you

Errors
java.lang.OutOfMemoryError: Failed to allocate a 28 byte allocation with 11 free bytes and 11B until OOM
at java.lang.String.<init>(String.java:233)
at java.lang.String.<init>(String.java:206)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:326)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readMap(B4XSerializator.java:229)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:345)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readList(B4XSerializator.java:244)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:343)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readMap(B4XSerializator.java:229)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readType(B4XSerializator.java:273)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:355)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readMap(B4XSerializator.java:229)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readType(B4XSerializator.java:273)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:355)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ReadObject(B4XSerializator.java:110)
at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.ReadB4XObject(RandomAccessFile.java:323)
at dev.meta.sb.cclientsync._readobject(cclientsync.java:278)
at dev.meta.sb.cclientsync._jobdone(cclientsync.java:204)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.keywords.Common$5.run(Common.java:996)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6134)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
java.lang.OutOfMemoryError: OutOfMemoryError thrown while trying to throw OutOfMemoryError; no stack available
Errore: java.lang.Exception: java.lang.OutOfMemoryError: Failed to allocate a 28 byte allocation with 11 free bytes and 11B until OOM java.lang.OutOfMemoryError: Failed to allocate a 28 byte allocation with 11 free bytes and 11B until OOM
at java.lang.String.<init>(String.java:233)
at java.lang.String.<init>(String.java:206)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:326)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readMap(B4XSerializator.java:229)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:345)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readList(B4XSerializator.java:244)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:343)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readMap(B4XSerializator.java:229)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readType(B4XSerializator.java:273)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:355)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readMap(B4XSerializator.java:229)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readType(B4XSerializator.java:273)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:355)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ReadObject(B4XSerializator.java:110)
at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.ReadB4XObject(RandomAccessFile.java:323)
at dev.meta.sb.cclientsync._readobject(cclientsync.java:278)
at dev.meta.sb.cclientsync._jobdone(cclientsync.java:204)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.keywords.Common$5.run(Common.java:996)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6134)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
 

Roberto P.

Well-Known Member
Licensed User
Longtime User
wrong! I still have the problem. He fails to free memory while importing a lot of data:

java.lang.OutOfMemoryError: Failed to allocate a 44-byte allocation with 0 bytes free and 3GB until OOM
at libcore.io.Posix.recvfromBytes (Native Method)
at libcore.io.Posix.recvfrom (Posix.java:154)
at libcore.io.BlockGuardOs.recvfrom (BlockGuardOs.java:245)
at libcore.io.IoBridge.recvfrom (IoBridge.java:565)
at java.nio.SocketChannelImpl.readImpl (SocketChannelImpl.java:342)
at java.nio.SocketChannelImpl.read (SocketChannelImpl.java:304)
at de.tavendo.autobahn.WebSocketReader.run (WebSocketReader.java:654)
java.util.concurrent.TimeoutException: com.android.internal.os.BinderInternal $ GcWatcher.finalize () timed out after 10 seconds
at java.lang.ref.FinalizerReference.add (FinalizerReference.java:54)
com.android.internal.os.BinderInternal at $ GcWatcher.finalize (BinderInternal.java:51)
java.lang.Daemons at $ FinalizerDaemon.doFinalize (Daemons.java:209)
java.lang.Daemons at $ FinalizerDaemon.run (Daemons.java:192)
at java.lang.Thread.run (Thread.java:818)
 
Upvote 0

eps

Expert
Licensed User
Longtime User
Of course giving more memory just means that at some point you are likely to run out of it but not until you start working with more data.

@Erel also mentioned "Another option is to split it into multiple objects."

What is the App attempting to do? A little more detail would help.
 
Upvote 0
Top