如何确定最大堆栈大小限制?
我想从 Java 中以编程方式确定堆栈的最大大小(由 -Xss 设置的大小)。我该怎么做?
或者,由于我的 Java 模块也使用本机代码模块,因此我可以通过 JNI 来完成此操作;但如何呢?
I want to determine the maximum size of the stack programmatically from within Java (the size set by -Xss). How do I do this?
Alternatively, as my Java module also uses a native code module, I would be able to do this via JNI; but how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
ManagementFactory.getRuntimeMXBean().getInputArguments()
访问传递给 VM 的所有参数。Use
ManagementFactory.getRuntimeMXBean().getInputArguments()
to access all arguments passed to VM.也许不是最佳实践,但肯定很简单:我会编写一个递归方法来计算一个值,重复直到 java.lang.StackOverflowError 并查看计数器。
Maybe not best practice but certainly straight-forward: I'd write a recursive method counting up a value, recurring until java.lang.StackOverflowError and look at the counter.