Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file still open when call closeDocument #323

Closed
annpeter opened this issue Dec 5, 2023 · 5 comments
Closed

file still open when call closeDocument #323

annpeter opened this issue Dec 5, 2023 · 5 comments

Comments

@annpeter
Copy link

annpeter commented Dec 5, 2023

1、I use icepdf to open one pdf file
2、close the pdf in icepdf(call the closeDocument method), not close the application
3、I go to File Manager for Operating System, then change the file name i had open before.
4、I received an error indicating that the file is still open

image

pcorless pushed a commit that referenced this issue Dec 6, 2023
@pcorless
Copy link
Owner

pcorless commented Dec 6, 2023

I just pushed a branch that has few small changes. However, after a bit of debugger time I can't see any dangling file descriptors or input streams laying around after the document is closed. That said I am on linux and the file system config is a bit different then on windows.

Did you happen to save file changes or export changes? Or was simply open and close a document?

@annpeter
Copy link
Author

annpeter commented Dec 6, 2023

I have did some research and it appears that the MappedByteBuffer maps the memory of the file, but Java does not provide an interface to control the closure of this MappedByteBuffer mapping.

https://stackoverflow.com/questions/25238110/how-to-properly-close-mappedbytebuffer

The process of research is as follows: I first debugged step by step to determine which code segment the file would be occupied after entering, and when I called this MappedByteBuffer, I added my own code and immediately closed documentFileChannel, but still couldn't release the file

image

@pcorless
Copy link
Owner

pcorless commented Dec 7, 2023

Thank you for pointing me at that issue. And it would seem to explain why I'm not seeing it on Linux. I've updated the above branch with a more memory intensive change that might get around the lock issue you are seeing. If you have the means please let me know if it corrects the problem on Windows.

@annpeter
Copy link
Author

annpeter commented Dec 8, 2023

yes, it works.

pcorless pushed a commit that referenced this issue Jan 25, 2024
pcorless pushed a commit that referenced this issue Jan 25, 2024
@pcorless
Copy link
Owner

Will be in the 7.1.4 release.

pcorless added a commit that referenced this issue Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants