We have a swing based application that performs complex data processing. One of the prerequisites for our software is that any column cannot have too many unique values. If the number is numeric, the user will need to sample the data before they can use our tool.
Unfortunately, the algorithms we use are combinatorially expensive in memory, depending on the number of unique values ββfor each column. Right now, with the wrong data set, the application will quickly run out of memory. Before performing one of these operations that would end in memory, we should be able to calculate approximately how much memory the operation will require. It would be nice if we could check how much memory is currently being used in the application, evaluate whether the application will run out of memory, and display an error message rather than run out of memory. Using java.lang.Runtime, we can find free memory, shared memory and maximum memory, but is it really useful? Even if it turns out, we donβt have enough space for a heap, maybe if we wait 30 milliseconds,The garbage collector will start, and we will have enough heap space to start our operation. Is there anyway to really predict if we run out of memory?
source
share