Android Question [SOLVED] BLE2 and java.lang.StackOverflowError: stack size 8MB

Star-Dust

Expert
Licensed User
Longtime User
My Android device connects with a peripheral with the BLE2 library. Everything works correctly.
When I request the LOGs that are 5k long, it gives me an error. It seems like it's over the limit.

How can I solve this problem?
** Activity (main) Resume **
5568 (Len File)
java.lang.StackOverflowError: stack size 8MB
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:452)
at java.lang.StringBuilder.append(StringBuilder.java:137)
at java.lang.StringBuilder.<init>(StringBuilder.java:114)
at anywheresoftware.b4a.debug.Debug.shouldDelegate(Debug.java:245)
at it.tecnomedia.xxx.starter._readfile(starter.java:176)
Message longer than Log limit (4000). Message was truncated.
 

DonManfred

Expert
Licensed User
Longtime User
When I request the LOGs that are 5k long,

Do not use LOG then. B4a LOG is restricted to 4000 bytes approx.
Write it to a file and read the file then
 
Last edited:
Upvote 1
Solution

Star-Dust

Expert
Licensed User
Longtime User
I expressed myself badly, it's not the log that crashes the application. the data that the device sends is approximately 5k and the maximum that the HEAP memory can receive is 4K, this generates a crash within the library.

The ideal is that in the library there was a method that instead of transferring data into an Array transferred it directly to a file.
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Do not use LOG then. B4a LOG is restricted to 4000 bytes approx.
Write it to a file and read the file then
Rereading your message, I realized that the suggestion you gave me was correct, it was me who hadn't understood.

Reviewing the logs reporting an overflow, I found the error was a simple logical error

Thanks again for your observation, it was very useful
 
Last edited:
Upvote 0
Top