Why is it not a bad idea to delete things at garbage collection time!

This came about when I am using the Apache commons file upload

Here is that link

Here is the commons API. See for FileItem

the FileItem object deletes the file when it is garbage collected. This is ok, and looks like a good precaution if one is to explicitly forgot to call delete on it.

however if you want to wait for a subsequent time to process that file and if the garbage collector is to kick off, you may loose the file unintentionally! This means either you have to carry that FileItem as is and keep it alive or immediately transfer it to a file.

More to think on this, and see what the general recommendation and experience is of people doing things on garbage collection...