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

Delete temp DLLs and whole temp folder after processing #1170

Closed
lfcnassif opened this issue Jun 18, 2022 · 11 comments
Closed

Delete temp DLLs and whole temp folder after processing #1170

lfcnassif opened this issue Jun 18, 2022 · 11 comments
Assignees

Comments

@lfcnassif
Copy link
Member

Since a long ago, we weren't able to delete the temp folder because of loaded DLLs. They are unloaded just when the class loader that loaded them is garbage collected, which is a difficult situation to trigger.

Now that we have a start up process, I think it should be able to clean the temp folder without problems.

@patrickdalla
Copy link
Collaborator

patrickdalla commented Jun 18, 2022 via email

@lfcnassif
Copy link
Member Author

Unfortunatelly there are some dependencies that extract their own DLLs to java default temp dir to load them...

@patrickdalla
Copy link
Collaborator

patrickdalla commented Jun 18, 2022 via email

@lfcnassif
Copy link
Member Author

Yes, that is an old ideia. That is exactly the current bootstrap process, it finishes after the main process finishes, so we won't need to start a third process.

@patrickdalla
Copy link
Collaborator

patrickdalla commented Jun 18, 2022 via email

@lfcnassif
Copy link
Member Author

it finishes after the main process finishes

It is done so the bootstrap process can redirect standard streams from/to the main process to/from console, etc

Maybe it could do other things in the future, like resuming processing automatically for some kind of errors (like OOME), etc, but that is another history...

@lfcnassif
Copy link
Member Author

So, I'll try to implement this to clean up the temp folder if the index data wasn't created in temp dir when processing (it is needed by --continue) or if the main process is the analysis UI.

@lfcnassif
Copy link
Member Author

lfcnassif commented Apr 12, 2023

I'm almost finishing this, but some folders aren't being deleted on Windows because of forbidden NTFS chars in their name. Any tip on how to workaround this with a native windows command?

@lfcnassif
Copy link
Member Author

lfcnassif commented Apr 12, 2023

Found a workaround here: https://learn.microsoft.com/en-us/troubleshoot/windows-server/backup-and-storage/cannot-delete-file-folder-on-ntfs-file-system

This worked from powershell:
rm -Force -Recurse "\\?\full_folder_path"

@lfcnassif
Copy link
Member Author

Now temp folders and files, including loaded DLLs and memory mapped files, are always deleted when application exits, normally or not, except the index dir if it exits in temp because --continue needs it. It won't work if user aborts the application abruptly, e.g. using Ctrl+c

@lfcnassif lfcnassif changed the title Delete temp folder from Bootstrap process Delete DLLs and temp folder from Bootstrap process Apr 13, 2023
@lfcnassif
Copy link
Member Author

Just an update, new File("\\\\?\\" + file.getAbsolutePath()).delete(); also worked for NTFS files which names end with space, so I updated the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants