问题
How can I set maximum stack size?
I use jEdit to search with regular expression in rather big file (73 kb) and it fails with StackOverflowException.
I tried to set -Xss40m but it seems to be initial stack size and after some time it fails with following exception
11:45:31 AM [AWT-EventQueue-0] [error] AWT-EventQueue-0: Exception in thread "AWT-EventQueue-0"
11:45:31 AM [AWT-EventQueue-0] [error] AWT-EventQueue-0: java.lang.OutOfMemoryError: unable to create new native thread
11:45:31 AM [AWT-EventQueue-0] [error] AWT-EventQueue-0: at java.lang.Thread.start0(Native Method)
11:45:31 AM [AWT-EventQueue-0] [error] AWT-EventQueue-0: at java.lang.Thread.start(Unknown Source)
11:45:31 AM [AWT-EventQueue-0] [error] AWT-EventQueue-0: at java.awt.EventQueue.initDispatchThread(Unknown Source)
11:45:31 AM [AWT-EventQueue-0] [error] AWT-EventQueue-0: at java.awt.EventDispatchThread.run(Unknown Source)
I would appreciate if you explain me why OutOfMemory is thrown and also how to set max stack size.
回答1:
Perhaps you should set the heap memory size as so:
java -Xms 512m -Xmx 1024m
来源:https://stackoverflow.com/questions/7063103/java-set-max-stack-size