3 ms·
> The TerrariaClone.init() method, which is over 1,300 lines long, actually grew so large that the Java compiler started running out of memory trying to compile
by zokier 9y ago
> The TerrariaClone.init() method, which is over 1,300 lines long, actually grew so large that the Java compiler started running out of memory trying to compile it!
Seems surprising, 1.3kloc doesn't feel that big in the scale of things. I wouldn't be surprised if some of the methods at $work would be on the same scale, and it compiles just fine (relatively speaking..). And based on quick scroll-through, there isn't really anything especially egregious in there that would point towards why the compiler fails.
- ecshafer 9y agoNot having looked at the code, my guess would be what the 1k+ loc of method is doing. If it's mainly a bunch or if elsea or a switch statement that jumps to another function, which is what most gross long Enterprise code is, I imagine it's fine. But if you have 1k loc that is procedurally creating objects and doing a lot that depends on previous operations then I could see starting to run out of memory. We also don't know how much memory they had, most Java code for Enterprise is running on pretty big servers or workstations.
- tigershark 9y agoIn one of my previous jobs there was ClassSomething1, ClassSomething2 until 5 just because java can't have more than 65535 methods in a class..
- jcl 9y agoGiven the relative size of the function and typical memory, I suspect that the issue the author ran into was actually the JVM's 64KB limit on the bytecode size of a compiled function. https://stackoverflow.com/questions/17422480/maximum-size-of-a-method-in-java-7-and-8 https://stackoverflow.com/questions/17422480/maximum-size-of...