HTML to PDF / DOCX / RTF Java converter library › Forums › PD4ML v3 Archived Forums (Read Only) › Troubleshooting › Render crashes and heap space fills
- This topic has 2 replies, 2 voices, and was last updated Oct 01, 2012
19:27:28 by PD4ML.
-
AuthorPosts
-
September 17, 2012 at 22:08#26779
When an certain snippet of HTML exists in a document, it will make the renderer enter some kind of death spiral where it will fill up the heap until the machine stops responding.
The snippet seems to be
<br /> <SPAN style="white-space:pre" class="Apple-tab-span"> </SPAN><br />
In context of a very simple example:
<br /> <table><br /> <tr><br /> <td><br /> TEXT<br /> <!--<SPAN style="white-space:pre" class="Apple-tab-span"> </SPAN>--><br /> MORE TEXT<br /> <SPAN style="white-space:pre" class="Apple-tab-span"> </SPAN><br /> FINAL TEXT<br /> </td><br /> </tr><br /> </table><br />
Here’s a histogram of my heap after trying to render this HTML:
<br /> num #instances #bytes class name <hr class="bbcode_rule" /> 1: 12253005 784192320 org.zefer.html.doc.view.b<br /> 2: 517 55412344 [Ljava.lang.Object;<br /> 3: 26309 3785624 <constMethodKlass><br /> 4: 26309 3590760 <methodKlass><br /> 5: 2671 2474760 [B<br /> 6: 1786 2400848 <constantPoolKlass><br /> 7: 1786 1494536 <instanceKlassKlass><br /> 8: 1504 1396576 <constantPoolCacheKlass><br /> 9: 18028 1279584 [C<br /> 10: 8536 603344 [I<br /> 11: 18388 588416 java.lang.String<br /> 12: 12400 396800 java.util.HashMap$Entry<br /> 13: 457 321504 <methodDataKlass><br /> 14: 1966 242192 java.lang.Class<br /> 15: 2781 204224 [S<br /> 16: 2765 173064 [[I<br /> 17: 6991 111856 java.lang.Integer<br /> 18: 304 108560 [Ljava.util.HashMap$Entry;<br /> 19: 163 95192 <objArrayKlassKlass><br /> 20: 1761 56352 java.util.concurrent.ConcurrentHashMap$HashEntry<br />
And the following is a very short Java program to demonstrate the issue:
<br /> String html = "<table><tr><td>TEXT<SPAN style="white-space:pre" class="Apple-tab-span"> </SPAN>MORE TEXT<SPAN style="white-space:pre" class="Apple-tab-span"> </SPAN>FINAL TEXT</td></tr></table>";<br /> StringReader sr = new StringReader(html);<br /> OutputStream os = new ByteArrayOutputStream();<br /> <br /> PD4ML pd4ml = new PD4ML();<br /> pd4ml.enableDebugInfo();<br /> pd4ml.useTTF( "java:", true );<br /> pd4ml.setHtmlWidth(1050);<br /> pd4ml.enableSmartTableBreaks(true);<br /> <br /> try {<br /> pd4ml.render(sr, os);<br /> } catch (Exception e) { }<br /> <br /> sop(((ByteArrayOutputStream)os).toByteArray());<br />
September 18, 2012 at 14:14#29116We reproduced the problem and work on it.
October 1, 2012 at 19:27#29117The problem is fixed in the development build. To be released in 2-3 days.
-
AuthorPosts
The forum ‘Troubleshooting’ is closed to new topics and replies.