question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OutOfMemoryError while deserializing messages

See original GitHub issue

Originally 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:closed
  • Created 8 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mikehearncommented, Jun 11, 2015
Closing with the assumption this was fixed by the patch, please re-open if not.

Reported by miron@google.com on 2011-10-14 21:42:45

  • Status changed: Fixed
  • Labels added: Component-Logic
1reaction
mikehearncommented, Jun 11, 2015
Patch posted to mailing list.

Reported by hearn@google.com on 2011-09-05 14:51:10

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found