Java设置最大堆栈大小 [英] java set max stack size
本文介绍了Java设置最大堆栈大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何设置最大堆栈大小?
How can I set maximum stack size?
我使用jEdit在较大的文件(73 kb)中使用正则表达式进行搜索,但由于StackOverflowException而失败.
I use jEdit to search with regular expression in rather big file (73 kb) and it fails with StackOverflowException.
我尝试设置-Xss40m,但是它似乎是初始堆栈大小,一段时间后它失败,并出现以下异常
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)
如果您能解释为什么抛出OutOfMemory以及如何设置最大堆栈大小,我将不胜感激.
I would appreciate if you explain me why OutOfMemory is thrown and also how to set max stack size.
推荐答案
也许您应该这样设置堆内存大小:
Perhaps you should set the heap memory size as so:
java -Xms 512m -Xmx 1024m
这篇关于Java设置最大堆栈大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文