OutOfMemoryError while deserializing messages
See original GitHub issueOriginally reported on Google Code with ID 73
I have analyzed all the OutOfMemoryErrors happening inside Bitcoin Wallet. More than
50% of it happen here:
java.lang.OutOfMemoryError: (Heap Size=32519KB, Allocated=30064KB, Bitmap Size=256KB)
at com.google.bitcoin.core.BitcoinSerializer.deserialize(BitcoinSerializer.java:181)
at com.google.bitcoin.core.NetworkConnection.readMessage(NetworkConnection.java:153)
at com.google.bitcoin.core.Peer.run(Peer.java:131)
at com.google.bitcoin.core.PeerGroup$PeerExecutionRunnable$1.run(PeerGroup.java:248)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
at java.lang.Thread.run(Thread.java:1027)
By looking at the code, I discoverd BitCoinJ allows a message size of up to 32 MB (Message.MAX_SIZE).
Is this realistic?
On Android, there is typically only a heap of 4 MB, so there is no way to read a 32
MB message into memory completely.
Is it possible to make out a more realistic message size limit, like 1 MB or even less?
Blocks currently cannot be larger than half a meg; is there any larger message in the
Bitcoin protocol?
Also, since the memory allocation at the above line seems to be a neuralgic point,
can we improve error handling at this point? Maybe handle this as a protocol error
(which would not crash the app)? Maybe include more debug info with the exception,
like the message size?
Reported by andreas.schildbach
on 2011-08-21 13:48:09
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
OutOfMemoryError when serializing/deserializing large object
I'm getting OutOfMemoryError when serializing with Java heap space or deserializing with GC overhead limit exceeded. Caused by: java.lang.
Read more >Message receiver - Out Of Memory during deserialization #1544
This looks to be happening while trying to process a network message. Specifically, de-serializing the body. Do you have a sense of what...
Read more >Json.Net deserialize out of memory issue - Stack Overflow
I am facing an issue where even with the use of a StreamReader to deserialize json data, it still getting the out of...
Read more >What is causing an OutOfMemoryError in com.ibm.ws.session?
Problem. An OutOfMemoryError may occur in WebSphere Application Server with stack frames in com.ibm.ws.session.*. Symptom.
Read more >HTTP Client Deserialize JSON result in OOM (Out Of Memory ...
After investigated the main reason was caused by the data volume from database return to API that increased from 100K to 360K records...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Reported by
miron@google.com
on 2011-10-14 21:42:45Fixed
Reported by
hearn@google.com
on 2011-09-05 14:51:10