You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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:
and you can clearly see that native memory grows and GC cannot clear it
This is the memory profiler results after the code commenting:
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)
@barteksc Please share your thoughts on this issue? Please let me know whether it's fine that I've just commented these lines? Or is there some purpose for such memory copying?
Glad to hear your comments.
Thanks
UPDATE.
After several tests I made a conclusion that the approach describe above is not acceptable.
It works in some scenarios but also crashes in others (I cannot describe the details here because of the NDA)
After some research, I created a new code version that works in all the scenarios.
These are the changes that I made:
@AhmerAfzal1 Should I also include in the pull request the other changes required for the NDK to be able to build it with the latest Android Studio version?
Such changes are:
APP_PLATFORM = android-19 // modern NDK doesn't support the android-14 which is currently specified in the code
removed mips and mips64 support // the same reason as above
@AhmerAfzal1 Should I also include in the pull request the other changes required for the NDK to be able to build it with the latest Android Studio version? Such changes are:
APP_PLATFORM = android-19 // modern NDK doesn't support the android-14 which is currently specified in the code
removed mips and mips64 support // the same reason as above
It's best to create a pull request that includes your latest change to this repo. Make it easy for authors and other users to see the new changing and fixed bugs, always make a pull request in which you participate improves this great library.
Activity
ViktorSkabiak commentedon May 16, 2022
@barteksc Please share your thoughts on this issue? Please let me know whether it's fine that I've just commented these lines? Or is there some purpose for such memory copying?
Glad to hear your comments.
Thanks
ViktorSkabiak commentedon May 16, 2022
UPDATE.
After several tests I made a conclusion that the approach describe above is not acceptable.
It works in some scenarios but also crashes in others (I cannot describe the details here because of the NDA)
After some research, I created a new code version that works in all the scenarios.


These are the changes that I made:
The whole code is here:
mainJNILib.txt
@barteksc Glad to hear your opinion
Thanks
AhmerAfzal1 commentedon May 18, 2022
@ViktorSkabiak You should create a pull request to fix this issue.
ViktorSkabiak commentedon May 18, 2022
@AhmerAfzal1 Should I also include in the pull request the other changes required for the NDK to be able to build it with the latest Android Studio version?
Such changes are:
AhmerAfzal1 commentedon May 19, 2022
It's best to create a pull request that includes your latest change to this repo. Make it easy for authors and other users to see the new changing and fixed bugs, always make a pull request in which you participate improves this great library.
fix barteksc/PdfiumAndroid#84