I am writing a function in Java which has to recursively call itself a lot of times (in the range of ~10000). After reaching some level of recursion (~3250 atm), the Java thread just holds and has to be restarted. This is not influenced by the amount of RAM the jvm is started with (currently it's 2GB).
How can I influence the maximum level of nesting my jvm can handle?