如何分析java线程转储?(How to analyze a java thread dump?)
我正在尝试更多地了解java,特别是关于内存管理和线程。 为此,我最近有兴趣看看线程转储。
以下是使用VisualVM的Web应用程序的几行,这是一个内置的java工具:
"Finalizer" daemon prio=8 tid=0x02b3d000 nid=0x898 in Object.wait() [0x02d0f000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x27ef0288> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118) - locked <0x27ef0288> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134) at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159) Locked ownable synchronizers: - None "Reference Handler" daemon prio=10 tid=0x02b3b800 nid=0x494 in Object.wait() [0x02cbf000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x27ef0310> (a java.lang.ref.Reference$Lock) at java.lang.Object.wait(Object.java:485) at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116) - locked <0x27ef0310> (a java.lang.ref.Reference$Lock)
首先我有一些变量名称的问题:
- tid和nid是什么意思?
- Object.wait之后的圆括号中的数字是多少?
然后对于堆栈跟踪本身:
- 什么意思等于<.....>(一个java.lang ....) ,什么是<..>中的数字
- 这是什么意思锁定<.....>(一个java.lang ....)同样的问题,什么在<..>
我以为这个词被锁在一个等待状态,但是我错了。 其实我想知道为什么锁定重复三次,但线程处于可运行状态,如同样的转储中所示:
"Thread-0" prio=6 tid=0x02ee3800 nid=0xc1c runnable [0x03eaf000] java.lang.Thread.State: RUNNABLE at java.io.FileInputStream.readBytes(Native Method) at java.io.FileInputStream.read(FileInputStream.java:199) at java.io.BufferedInputStream.read1(BufferedInputStream.java:256) at java.io.BufferedInputStream.read(BufferedInputStream.java:317) - locked <0x23963378> (a java.io.BufferedInputStream) at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264) at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306) at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158) - locked <0x23968450> (a java.io.InputStreamReader) at java.io.InputStreamReader.read(InputStreamReader.java:167) at java.io.BufferedReader.fill(BufferedReader.java:136) at java.io.BufferedReader.readLine(BufferedReader.java:299) - locked <0x23968450> (a java.io.InputStreamReader) at java.io.BufferedReader.readLine(BufferedReader.java:362) at org.codehaus.plexus.util.cli.StreamPumper.run(StreamPumper.java:145)
最后,这是最糟糕的:
"CompilerThread0" daemon prio=10 tid=0x02b81000 nid=0x698 waiting on condition [0x00000000] java.lang.Thread.State: RUNNABLE
该线程处于可运行状态,但正在等待状态。 什么条件和什么是0x00000?
为什么堆栈跟踪很短,没有任何线程类的证据?
如果你能回答我所有的问题,我将非常感激。
谢谢
I am trying to understand more about java, especially about memory management and threads. For this reason I have recently found interest in looking at thread dumps.
Here are few lines taken from a web app using VisualVM, a built-in tool for java:
"Finalizer" daemon prio=8 tid=0x02b3d000 nid=0x898 in Object.wait() [0x02d0f000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x27ef0288> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118) - locked <0x27ef0288> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134) at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159) Locked ownable synchronizers: - None "Reference Handler" daemon prio=10 tid=0x02b3b800 nid=0x494 in Object.wait() [0x02cbf000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x27ef0310> (a java.lang.ref.Reference$Lock) at java.lang.Object.wait(Object.java:485) at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116) - locked <0x27ef0310> (a java.lang.ref.Reference$Lock)
First I have questions about some variable names:
- what does tid and nid mean?
- What is the figure in squared parenthesis after Object.wait?
Then for the stack trace itself:
- what does it mean waiting on <.....> (a java.lang....) and what's the number in <..>
- what does it mean locked <.....> (a java.lang....) same question, what's in <..>
I thought that the word locked was related in someway to a wait condition, however, I was wrong. In fact, I am wondering why locked is repeated three times, but the thread is in runnable state as seen in the same dump:
"Thread-0" prio=6 tid=0x02ee3800 nid=0xc1c runnable [0x03eaf000] java.lang.Thread.State: RUNNABLE at java.io.FileInputStream.readBytes(Native Method) at java.io.FileInputStream.read(FileInputStream.java:199) at java.io.BufferedInputStream.read1(BufferedInputStream.java:256) at java.io.BufferedInputStream.read(BufferedInputStream.java:317) - locked <0x23963378> (a java.io.BufferedInputStream) at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264) at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306) at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158) - locked <0x23968450> (a java.io.InputStreamReader) at java.io.InputStreamReader.read(InputStreamReader.java:167) at java.io.BufferedReader.fill(BufferedReader.java:136) at java.io.BufferedReader.readLine(BufferedReader.java:299) - locked <0x23968450> (a java.io.InputStreamReader) at java.io.BufferedReader.readLine(BufferedReader.java:362) at org.codehaus.plexus.util.cli.StreamPumper.run(StreamPumper.java:145)
Then last of all, this was the worst of them:
"CompilerThread0" daemon prio=10 tid=0x02b81000 nid=0x698 waiting on condition [0x00000000] java.lang.Thread.State: RUNNABLE
This thread is in runnable state, but it's waiting on condition. What condition and what is 0x00000?
Why the stack trace is so short without any evidence of the thread class?
If you could answer to all my questions I would be very grateful.
Thanks
原文:https://stackoverflow.com/questions/7599608
最满意答案
如何这样的事情:
WebDataSource *dataSource = [[sourceSignatureWebView mainFrame] dataSource]; WebArchive *archive = [[WebArchive alloc] initWithMainResource:[dataSource mainResource] subresources:nil subframeArchives:nil]; [[archive data] writeToURL…
或者,你是否真的在HTML文件而不是网络存档之后?
How about something like this:
WebDataSource *dataSource = [[sourceSignatureWebView mainFrame] dataSource]; WebArchive *archive = [[WebArchive alloc] initWithMainResource:[dataSource mainResource] subresources:nil subframeArchives:nil]; [[archive data] writeToURL…
Or are you actually after an HTML file rather than web archive?
相关问答
更多-
webarchive是什么文件?怎么打开webarchive文件[2023-10-03]
方法一:右击该文件,在弹出的菜单中会有“用xx程序打开”,继续选择,会有复式菜单,如果其中有IE,则选择即可,如果没有,你点“浏览”,在弹出的对话框中找到IE并确认即可。 方法二:先保存,文件夹选项里让所有文件显示后缀名;然后将后缀名修改为html就可以打开了,截图成jpg就可以了。 -
webarchive文件用什么软件打开?[2023-07-30]
mac(苹果系统)用safari直接打开 -
如何打开WEBARCHIVE 格式文件[2023-07-09]
先保存了,文件夹选项里让所有文件显示后缀名; 然后将后缀名修改为html就可以打开了,截图成jpg就可以了; 我朋友刚帮我搞定过。 -
如何这样的事情: WebDataSource *dataSource = [[sourceSignatureWebView mainFrame] dataSource]; WebArchive *archive = [[WebArchive alloc] initWithMainResource:[dataSource mainResource] subresources:nil ...
-
使用-loadData:...将起作用。 指定的MIME类型必须是application/x-webarchive (不是通用的“octet-stream”)。 如果设置正确,则文本编码和基本URL都可以作为nil提供。 Using -loadData:... will work. The MIME type specified must be application/x-webarchive (not the generic "octet-stream"). If this is set correctl ...
-
如果你想使用像素,CGImage和CGImageSource以及CGImageDestination是要走的路。 与AppKit的NSImage不同,后者通常是为处理任何类型的图像而设计的,CGImage类是专门为光栅图像设计的。 If you want to work with pixels, CGImage and CGImageSource and CGImageDestination are the way to go. Unlike AppKit's NSImage, which is desig ...
-
在QTKit.framework中查看QTMovie 。 特别是,一旦你创建了一个电影实例,就可以使用-[QTMovie addImage:forDuration:withAttributes:]为电影添加一个“框架”。 Have a look at QTMovie in QTKit.framework. In particularly, once you've created a movie instance, you can use -[QTMovie addImage:forDuration:with ...
-
维基百科图像未从UIWebView中的webarchive加载(Wikipedia Images aren't loading from a webarchive in UIWebView)[2022-02-13]
Ilnar是对的。 扩展他的答案,iOS7 srcset支持不支持属性srcset这很可能是导致你看到的崩溃的原因。 Srcset用于在一个图像标记中为不同的设备大小提供多个图像链接。 开头有javascript,在return'srcset'in new Image();中找到图像return'srcset'in new Image();的正确src return'srcset'in new Image(); 新的webarchive使用此标记提供3个图像的链接。 OLD webarchive只是使用标记 ... -
在沉思Xcode可能正在做的事情后,我找到了一个解决方案: 这不起作用: WebArchive *archive = [[WebArchive alloc] initWithData:webData]; [[webView mainFrame] loadArchive:archive]; 但这样做: [[webView mainFrame] loadData:webData MIMEType:@"application/x-webarchive" textEncodingName:@"" baseURL: ...
-
通常,创建类/对象的原因是您希望它具有某种行为。 因此,如果您可能会对要保存的数据重复执行相同的操作,那么可能值得定义一个类。 如果您只是需要保存数据并在以后访问它,那么NSDictionary听起来是一个更明智的选择。 Typically, the reason for creating a class/object is when you expect it to have some sort of behaviour. So, if you're likely to repeatedly perfor ...