【问题标题】:can we find which thread is holding a lock in a heap dump file我们能在堆转储文件中找到哪个线程持有锁吗
【发布时间】:2022-01-07 00:47:34
【问题描述】:

像 jstack 命令一样有 -l 选项,其中包含锁定信息。

    Usage:
    jstack [-l] <pid>
        (to connect to running process)
    jstack -F [-m] [-l] <pid>
        (to connect to a hung process)
    jstack [-m] [-l] <executable> <core>
        (to connect to a core file)
    jstack [-m] [-l] [server_id@]<remote server IP or hostname>
        (to connect to a remote debug server)

Options:
    -F  to force a thread dump. Use when jstack <pid> does not respond (process is hung)
    -m  to print both java and native frames (mixed mode)
    -l  long listing. Prints additional information about locks
    -h or -help to print this help message

我想知道java是否在堆中存储锁信息?如果答案是肯定的,我们可以通过查看堆转储文件来检查线程锁吗?我正在使用 eclipse 内存 anlyazier 但不知道怎么做。

【问题讨论】:

  • 我想,这个数据没有存储在堆中,但是你可以在线程转储中找到它

标签: java heap-dump


【解决方案1】:

不知道堆中是否有锁信息。但是您可以使用 mat 内存分析器获取堆中的所有线程相关信息。您可以使用如下的 OQL 查询来查询特定的线程对象,然后分析线程对象的详细信息。

SELECT s FROM java.lang.Thread s WHERE toString(s.name)="pool-thread-1"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-10-07
    • 1970-01-01
    • 2023-03-30
    • 2011-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多