[ 
https://issues.apache.org/jira/browse/PDFBOX-3082?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15011331#comment-15011331
 ] 

Tilman Hausherr commented on PDFBOX-3082:
-----------------------------------------

[~tom.callahan] There was one bug in the patch, in readTrueTypeFont, the ttc is 
closed even if all goes well. This results in failure to render the file of 
PDFBOX-1658 on W7. That file uses two MS-Gothic fonts which are in a ttc in W7. 
I've removed the close there and modified the code.

Is there a reason that the interface is static? I have removed that as it is 
confusing.
https://stackoverflow.com/questions/8374646/what-is-a-static-interface-in-java
https://stackoverflow.com/questions/71625/why-would-a-static-inner-interface-be-used-in-java

I've made some minor changes, reformatted and added some javadoc.

[~msahyoun] please retest to be sure that the memory improvement is still there.

> High memory consumption while building font cache
> -------------------------------------------------
>
>                 Key: PDFBOX-3082
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3082
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 2.0.0
>            Reporter: Maruan Sahyoun
>            Priority: Blocker
>             Fix For: 2.0.0
>
>         Attachments: cpu_mem_info.png, heap-usage.png, 
> pdfbox-mem-20151117-2.patch, pdfbox-mem-20151117.patch, 
> pdfbox3082screenshot.png, retained_sizes.png
>
>
> When the font cache is build there is a very high memory consumption.
> For this small program
> {code}
>     public static void main(String[] args)
>     {
>         PDFont font = PDType1Font.HELVETICA;
>         try
>         {
>             System.in.read();
>         }
>         catch (IOException e)
>         {
>             // TODO Auto-generated catch block
>             e.printStackTrace();
>         }
>     }
> {code}
> I need to set {{-Xmx1512M}} in order to avoid an OOM
> Smaller memory settings will bring this
> {code}
> $ java -Xmx1256M -jar Test.jar 
> Nov 03, 2015 2:48:32 AM org.apache.pdfbox.pdmodel.font.FileSystemFontProvider 
> loadCache
> WARNUNG: New fonts found, font cache will be re-built
> Nov 03, 2015 2:48:32 AM org.apache.pdfbox.pdmodel.font.FileSystemFontProvider 
> <init>
> WARNUNG: Building font cache, this may take a while
> Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
>       at org.apache.fontbox.cff.IndexData.initData(IndexData.java:95)
>       at org.apache.fontbox.cff.CFFParser.readIndexData(CFFParser.java:163)
>       at org.apache.fontbox.cff.CFFParser.parseFont(CFFParser.java:393)
>       at org.apache.fontbox.cff.CFFParser.parse(CFFParser.java:115)
>       at org.apache.fontbox.ttf.CFFTable.read(CFFTable.java:53)
>       at org.apache.fontbox.ttf.TrueTypeFont.readTable(TrueTypeFont.java:377)
>       at org.apache.fontbox.ttf.OpenTypeFont.getCFF(OpenTypeFont.java:61)
>       at 
> org.apache.pdfbox.pdmodel.font.FileSystemFontProvider.addTrueTypeFontImpl(FileSystemFontProvider.java:432)
>       at 
> org.apache.pdfbox.pdmodel.font.FileSystemFontProvider.addTrueTypeCollection(FileSystemFontProvider.java:344)
>       at 
> org.apache.pdfbox.pdmodel.font.FileSystemFontProvider.scanFonts(FileSystemFontProvider.java:243)
>       at 
> org.apache.pdfbox.pdmodel.font.FileSystemFontProvider.<init>(FileSystemFontProvider.java:224)
>       at 
> org.apache.pdfbox.pdmodel.font.FontMapperImpl$DefaultFontProvider.<clinit>(FontMapperImpl.java:132)
>       at 
> org.apache.pdfbox.pdmodel.font.FontMapperImpl.getProvider(FontMapperImpl.java:151)
>       at 
> org.apache.pdfbox.pdmodel.font.FontMapperImpl.findFont(FontMapperImpl.java:415)
>       at 
> org.apache.pdfbox.pdmodel.font.FontMapperImpl.findFontBoxFont(FontMapperImpl.java:378)
>       at 
> org.apache.pdfbox.pdmodel.font.FontMapperImpl.getFontBoxFont(FontMapperImpl.java:352)
>       at 
> org.apache.pdfbox.pdmodel.font.PDType1Font.<init>(PDType1Font.java:114)
>       at 
> org.apache.pdfbox.pdmodel.font.PDType1Font.<clinit>(PDType1Font.java:76)
>       at PDFontTest.main(PDFontTest.java:11)
> {code}
> Possible cause is a large number of fonts on my system
> {code}
> Nov 03, 2015 2:56:01 AM org.apache.pdfbox.pdmodel.font.FileSystemFontProvider 
> loadCache
> WARNUNG: New fonts found, font cache will be re-built
> Nov 03, 2015 2:56:01 AM org.apache.pdfbox.pdmodel.font.FileSystemFontProvider 
> <init>
> WARNUNG: Building font cache, this may take a while
> Nov 03, 2015 2:56:22 AM org.apache.pdfbox.pdmodel.font.FileSystemFontProvider 
> saveCache
> WARNUNG: Finished building font cache, found 876 fonts
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org

Reply via email to