看到太多 lsof 无法识别协议

发布于 2024-12-12 01:43:06 字数 337 浏览 0 评论 0原文


我有一个 Java 进程/应用程序。当我在该 java 进程上运行 /usr/sbin/lsof -p 时,我看到很多“无法识别协议”。另外,有趣的是,文件描述符(FD)正在以非常稳定的速度增长。那些正在创建的 FD 的描述为“无法识别协议”。

那么,有没有什么方法可以检测/分析 java 进程,以便确定谁在创建这么多 FD。关于任何工具的任何详细解释都会非常有帮助。

谷歌的快速搜索告诉我 strace 是一种方法,但 IIUC 会显示来自 java 进程的 linux 系统调用。我更感兴趣的是我的 java 代码的哪一部分表现不佳,而不是正在生成的系统调用。

再说一次,任何想法/建议都会很棒!

I have a Java process/app. When I run /usr/sbin/lsof -p on that java process, I see a lot of "can't identify protocol". Also, interestingly, File descriptors(FDs) are increasing at a very steady rate. And those FDs that are being created are having description as "can't identify protocol".

So, is there any way to instrument/profile the java process so as to nail down who is creating that many FDs. Any detailed explanation on any tool would be really really helpful.

A quick google search tells me strace is one way but IIUC, that will show linux system calls coming out of the java process. I am more interested in which part of my java code is behaving badly than what system calls are being generated.

Again, any ideas/suggestions would be simply great!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

酒解孤独 2024-12-19 01:43:06

对于半开放的 TCP/IP 连接,Lsof 打印 can't recognize protocolhttps://idea.popcount.org/2012-12-09-lsof-cant-identify-protocol/

Lsof prints can't identify protocol for half-open TCP/IP connections: https://idea.popcount.org/2012-12-09-lsof-cant-identify-protocol/

栩栩如生 2024-12-19 01:43:06

当 lsof 打印“无法识别协议”时,这通常与套接字有关(它还应该在相关输出行中显示“sock”)。

因此,在代码中的某个地方,您可能正在连接套接字并且没有正确关闭它们(也许您需要一个finally块)。

我建议您使用调试器单步执行代码(最容易使用 IDE,如果需要,可以使用远程调试器),同时并行运行 lsof。您最终应该能够看到哪个线程/代码行正在创建这些文件描述符。

请参阅此常见问题解答的第 10.2.2 点,了解有关Lsof 输出。

When lsof prints "Can't identify protocol", this usually relates to sockets (it should also say 'sock' in the relevant output lines).

So, somewhere in your code you are probably connecting sockets and not closing them properly (perhaps you need a finally block).

I suggest you step through your code with a debugger (easiest to use your IDE, potentially with a remote debugger, if necesssary), while running lsof side-by-side. You should eventually be able to see which thread / line of code is creating these File Descriptors.

See point 10.2.2 of this FAQ for more details about the Lsof output.

星星的軌跡 2024-12-19 01:43:06

也许您在使用 SSL 和主机名时观察到 JVM 1.6 中存在连接泄漏的错误: https: //bugs.java.com/bugdatabase/view_bug?bug_id=6745052

Maybe you observe bug in JVM 1.6 with leak of connections when you use SSL and hostname: https://bugs.java.com/bugdatabase/view_bug?bug_id=6745052

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文