我们正在开发自10年以来开发的业务应用程序(100万+ LOC).在切换到JDK8时,我们遇到了JDK8的元空间问题.这似乎与com.sun.xml.ws:webservices-rt:1.4(Metro 1.4)中引用的JaxB-Version有关.由于应用程序中的密切链接以及通过JaxB创建类/实例的传统,因此动态切换旧库并不简单.
目前我们正在研究这个问题.我们创建了一个重现此行为的示例程序:
import java.io.ByteArrayInputStream;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class X
{
private static final String XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><x test=\"test\" />";
@XmlAttribute
String test;
public static void main( String[] args ) throws JAXBException, InterruptedException
{
System.out.println("start");
while ( true )
{
JAXBContext jc = JAXBContext.newInstance( X.class );
Unmarshaller unmarshaller = jc.createUnmarshaller();
X object = (X) unmarshaller.unmarshal( new ByteArrayInputStream( XML.getBytes() ) );
System.out.println( object.test );
}
}
}
Run Code Online (Sandbox Code Playgroud)
JDK7使PermGenSpace保持干净.(用16M PermGen模拟) …