线程抛出异常

您应当调查抛出异常或错误的线程。因为此类线程栈追踪信息通常指明了问题的起因所在。下方是抛出 java.lang.OutOfMemoryError 的线程的栈追踪信息:

Thread 0x3ff781e764e0
at java.lang.OutOfMemoryError.<init>()V (OutOfMemoryError.java:48)
at java.lang.ClassLoader.defineClass1(Ljava/lang/String;[BIILjava/security/ProtectionDomain;Ljava/lang/String;)Ljava/lang/Class; (Native Method)
at java.lang.ClassLoader.defineClass(Ljava/lang/String;[BIILjava/security/ProtectionDomain;)Ljava/lang/Class; (ClassLoader.java:757)
at java.lang.ClassLoader.defineClass(Ljava/lang/String;[BII)Ljava/lang/Class; (ClassLoader.java:636)
at sun.reflect.GeneratedMethodAccessor37.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; (Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; (Method.java:498)
at com.sun.xml.bind.v2.runtime.reflect.opt.Injector.inject(Ljava/lang/String;[B)Ljava/lang/Class; (Injector.java:125)
at com.sun.xml.bind.v2.runtime.reflect.opt.Injector.inject(Ljava/lang/ClassLoader;Ljava/lang/String;[B)Ljava/lang/Class; (Injector.java:48)
at com.sun.xml.bind.v2.runtime.reflect.opt.AccessorInjector.prepare(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)Ljava/lang/Class; (AccessorInjector.java:51)
at com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory.get(Ljava/lang/reflect/Field;)Lcom/sun/xml/bind/v2/runtime/reflect/Accessor; (OptimizedAccessorFactory.java:128)
at com.sun.xml.bind.v2.runtime.reflect.Accessor$FieldReflection.optimize(Lcom/sun/xml/bind/v2/runtime/JAXBContextImpl;)Lcom/sun/xml/bind/v2/runtime/reflect/Accessor; (Accessor.java:213)
at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.<init>(Lcom/sun/xml/bind/v2/runtime/JAXBContextImpl;Lcom/sun/xml/bind/v2/runtime/Transducer;Lcom/sun/xml/bind/v2/runtime/reflect/Accessor;)V (TransducedAccessor.java:195)
:
:
at com.sun.xml.ws.client.WSServiceDelegate.getPort(Ljavax/xml/namespace/QName;Ljava/lang/Class;[Ljavax/xml/ws/WebServiceFeature;)Ljava/lang/Object; (WSServiceDelegate.java:274)
at com.sun.xml.ws.client.WSServiceDelegate.getPort(Ljavax/xml/namespace/QName;Ljava/lang/Class;)Ljava/lang/Object; (WSServiceDelegate.java:267)

从以上栈追踪信息信息中,我们可以看到线程在尝试将 XML 转换为 Java 对象时遇到了 OutOfMemoryError。

显然,这里没有为该应用程序分配足够大的内存来处理大型 XML 负载。所以在大型 XML 被发送给该应用程序时,其出现了 OutOfMemoryError。在分配了足够的内存后(即:提高了 -Xmx 值),问题得到解决。因此在线程转储文件寻找异常或错误是确定问题根源的好方式。 fastThread 应用程序会在线程转储文件中寻找常见异常和错误,并在‘异常’部分中对其进行报告。下方是该部分的截图:

图:fastThread 报告中的‘异常’部分

您应该仔细检查这些线程的栈追踪信息,这样才能了解其是否是应用程序问题的潜在原因。

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: