I am working on an application written solely in Java which will often be using very large amount of data (at most 500 GB). The program will be saving data not currently in use in a database.
However, I want to keep as much data as possible within the application since a lot of it is reused often. In order to not get any out-of-memory errors I want to be able to check how much memory the application as a whole is using at any one moment, so that I can store it when the application approaches a predefined limit.
Something like this;
long memoryUsage = SomeClass.getCurrentMemoryUsage();