当我使用多个不同的请求运行以下代码时,java 元空间正在增加。
public String applyXsltOnXml(String xmlString, String xsltInput) throws TransformerException {
String result = null;
try (StringReader stringReader = new StringReader(xmlString);
StringWriter writer = new StringWriter()) {
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new StreamSource(new StringReader(xsltInput)));
transformer.transform(new StreamSource(stringReader), new StreamResult(writer));
result = writer.toString();
}
return result;
}
你能解释一下幕后发生的事情吗?为什么 java 元空间越来越大?