Skip to content

Memory leak when opening PDF as a byte array #84

@ViktorSkabiak

Description

@ViktorSkabiak

The library contains a memory leak when you open a PDF as a byte array.
I check the method nativeOpenMemDocument and found some weird memory copying code.
I've commented this code and memory leak has gone
image

TL;DR
I was running a 3 minutes autotest which opens the 50-pages PDF every 10 seconds.
This is the memory profiler results before the code commenting:
Screenshot 2022-05-16 at 06 23 49
and you can clearly see that native memory grows and GC cannot clear it

This is the memory profiler results after the code commenting:
Screenshot 2022-05-16 at 06 29 52
Now there is not such native memory issues. It stays relatively small and GC easily clears it

The issue was happening when I was calling the method PdfDocument newDocument(byte[] data, String password)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions