I need to load a file into memory. Before I do that I want to make sure that there is enough memory in my VM left. If not I would like to show an error message. I want to avoid the OutOfMemory
exception.
Approach:
- Get filesize of my file
- Use
Runtime.getRuntime().freeMemory()
- Check if it fits
Would this work or do you have any other suggestions?
Aucun commentaire:
Enregistrer un commentaire