On Fri, 10 Nov 2023 09:13:06 GMT, Long Yang <d...@openjdk.org> wrote:

> I would like to fix this.
> 
> Create 4096 threads, and the stack depth of each thread is 256. 
> After running jmx.dumpAllThreads(true, true), the RSS reaches 5.3GiB. 
> After optimization, the RSS is 250MiB.
> 
> I would appreciate it if anyone could review this.
> 
> ---------
> update
> 
> If the number of `threads` and `stack depth` are relatively large, we need to 
> apply for more space in `ResourceArea` during the execution of 
> `jmx.dumpAllThreads(true, true)`.
> 
> The reason is that `VM_ThreadDump::doit` creates `vframe` for each `frame` of 
> each `thread`.
> https://github.com/openjdk/jdk/blob/fe0ccdf5f8a5559a608d2e2cd2b6aecbe245c5ec/src/hotspot/share/services/threadService.cpp#L704
> sizeof `vframe` is 4808 (bytes), and sizeof `compiledVFrame` is 4824 (bytes), 
> mainly because the `xmm registers` in `RegisterMap` are relatively large. 
> Assuming there are 4096 `threads` and each `thread` has 256 `frames`, the 
> memory required is 4096 * 256 * 4824 = 4.7GiB。
> 
> These memories of all threads are released once by the the initial 
> `ResourceMark` of `VM_ThreadDump::doit`.
> https://github.com/openjdk/jdk/blob/fe0ccdf5f8a5559a608d2e2cd2b6aecbe245c5ec/src/hotspot/share/runtime/vmOperations.cpp#L269
> My solution is to add a `ResourceMark` for each thread.

This pull request has now been integrated.

Changeset: 8ec6b8de
Author:    yibo.yl <yibo...@alibaba-inc.com>
Committer: Denghui Dong <dd...@openjdk.org>
URL:       
https://git.openjdk.org/jdk/commit/8ec6b8de3bb3d7aeebdcb45d761b18cce3bab75e
Stats:     3 lines in 2 files changed: 0 ins; 2 del; 1 mod

8319876: Reduce memory consumption of VM_ThreadDump::doit

Reviewed-by: dholmes, stefank

-------------

PR: https://git.openjdk.org/jdk/pull/16598

Reply via email to