运行一段时间后,可以获得Java中线程使用的实际堆栈大小吗? [英] Can one obtain actual stack size used by a thread in Java after some time of running?

查看:219
本文介绍了运行一段时间后,可以获得Java中线程使用的实际堆栈大小吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个想法是帮助确定给定Java应用程序的最佳堆栈大小。

The idea would be to help determine the optimum stack size for a given Java application.

使用此信息可以完成的一件事是创建一个堆栈大小的范围表,线程可以在它们退出时修改,并且可以在应用程序退出时定期转储。

One thing that could be done with this information create a range-table of stack sizes which the threads could modify as they exit and which could be dumped periodically and at application exit.

编辑:这是在具有真实工作负载的客户机器上运行的,我无法让探查器访问。

EDIT2:回答一个答案,在每个线程的(IIRC)256Kb,我想知道现在有多接近现实需要的东西(我也想知道)如果这个问题可能不太相关,因为可能堆栈空间是按需分配的)。我们有一个基于消息传递和高度线程化的应用服务器,可运行从ARM手持设备到octo-core Linux,到中型和大型机的所有东西 - 我们可以感受到我们可以交易的位置(以及是否)在具有许多消息处理程序的系统上堆栈的堆栈空间。

In response to one answer, at (IIRC) 256Kb per thread, I have wondered for a while now how close that is to the reality of what's needed (I also wonder if this question might be not very relevant because perhaps stack space is allocated on demand). We have an application server which is based on message passing and highly threaded and runs on everything from an ARM handheld to octo-core Linux, to midrange and mainframes - it would be good to have a feeling for where (and if) we can trade stack space for heap on systems with many message handlers.

有一些类似的问题值得关注,但它们是本机的/特定于os的:

There are some similar questions which are of interest, but they are native/os-specific:

  • How to determine maximum stack usage?
  • How to determine optimal thread stack size?

推荐答案

很难获得堆栈内存。

通过 MemoryMXBean

这篇关于运行一段时间后,可以获得Java中线程使用的实际堆栈大小吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆