I am working on a program that loads files and uses their information to populate a Model
class. These files can range in size from a few KB to almost a GB. When their sizes fluctuate, so too does the memory used by the Model
class.
When I load a file that is large enough, I receive the OutOfMemoryError
.
I am able to reject a users request to load a file (based on the file size). How do I examine a file, determine its size, and then determine if the application can handle it?
Is there a way to make this adapt to the amount of RAM on a users' computer?