【发布时间】:2011-07-23 02:16:41
【问题描述】:
首先让我声明我根本不知道 XSLT。我的任务是调查在 XSLT 处理期间发生的 Java OutOfMemory 异常的一些 JVM 转储。
我发现 OutOfMemory 发生在递归 XSLT 处理期间(我们使用 XALAN)。
令我震惊的是,递归的深度超过了 100 000 次。
在什么情况下可以接受在 XSLT 处理期间如此深的递归?
请注意,线程堆栈跟踪大约有 300k 行长,并且在 OutOfMemory 发生之前填充了它的变体:
at org/apache/xalan/transformer/TransformerImpl.executeChildTemplates(Bytecode PC:150(Compiled Code))
at org/apache/xalan/templates/ElemElement.execute(Bytecode PC:352(Compiled Code))
at org/apache/xalan/transformer/TransformerImpl.executeChildTemplates(Bytecode PC:150(Compiled Code))
【问题讨论】:
-
可以创建一个导致无限递归的转换。你能发布你的模板吗?
-
这就是为什么这被称为stackoverflow...
-
好问题,+1。有关递归处理导致堆栈溢出的原因以及该问题的两种解决方案的详细说明,请参阅我的答案。