java set max stack size

笑着哭i 提交于 2019-12-13 06:29:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!