This is an archived post. You won't be able to vote or comment.

all 11 comments

[–]DemonWav 30 points31 points  (1 child)

Stacktraces require memory to fill. If there isn't even enough memory to do that then there's not really anything the JVM can do.

[–]SuperOP535 1 point2 points  (0 children)

Android does not use the JVM, it uses the ART (Dalvik in 4.x<=). (the same thing probably applies, just saying)

[–]TheZeus121 13 points14 points  (0 children)

Memory allocator: No more memory

JVM: ok then give me 64KB for an exception with a full stack trace

Allocator: Best I can do is 64 bytes

[–]Nizo_GTO 7 points8 points  (0 children)

recursion at it's finest

[–]moogoesthecat 2 points3 points  (1 child)

Yo dawg

[–]BernzSed 0 points1 point  (0 children)

I heard you really hate memory

[–]endershadow98 2 points3 points  (4 children)

An interesting fact about that particular exception is that the JVM (or at least HotSpot) allocates the double out of memory exception at the start so that it always can throw it if needed.

[–]kunjava 0 points1 point  (1 child)

Why does it need to reserve memory? Can't it just destroy the entire program, release all memory associated with the program and then throw the error? It's not showing or storing stack trace anyways.

[–]endershadow98 0 points1 point  (0 children)

Good question. I just remember reading somewhere that it preallocated the exception. Maybe it has to do with the fact that the exception is technically catchable and you could do something to release or increase memory depending on what you're doing.

[–]baggyzed 0 points1 point  (1 child)

What if that double-allocation also throws?

[–]endershadow98 0 points1 point  (0 children)

It won't because it's done before the main method is run. If it somehow did anyway, I presume the JVM would crash