[ https://issues.apache.org/jira/browse/PDFBOX-5731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17796252#comment-17796252 ]
liu commented on PDFBOX-5731: ----------------------------- 1、Keep the original commonNameMap. 2、When cleaning, you can use the ReferenceQueue to obtain the gc object and delete the key, such as the java.util.WeakHashMap#expungeStaleEntries method of weakashmap, which can reduce a lot of invalid traversals. You can try this to see if you can get support from the maintainers. I personally think that to really solve this problem, we can only cache the COSName of the current PDF scene instead of storing other PDFs, although this change is relatively large. > org.apache.pdfbox.cos.COSName#nameMap There is a memory leak problem. > --------------------------------------------------------------------- > > Key: PDFBOX-5731 > URL: https://issues.apache.org/jira/browse/PDFBOX-5731 > Project: PDFBox > Issue Type: Bug > Affects Versions: 2.0.30, 3.0.1 PDFBox > Reporter: liu > Priority: Major > Attachments: > attempted_fix_for_PDFBOX-5731__clear_out_unused_COSName_instances_automatically.patch, > image-2023-12-08-16-02-12-293.png, image-2023-12-13-17-04-22-073.png, > screenshot-1.png, screenshot-2.png, screenshot-3.png, screenshot-4.png, > screenshot-5.png > > > !image-2023-12-08-16-02-12-293.png! > !screenshot-1.png! -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org