Sjavac currently has heuristics to used to figure out how many threads and how many classes can be compiled at a time based on size of heap and if pointers are 32 or 64 bit. The problem is, this is currently happening in the client process and not the server process, so the information gathered might be wrong.
Also, the heuristics are very crude when reaching the conclusion that the amount of memory isn't enough for compiling everything in one batch. This makes compilation very slow if you happen to fall under the treshold.