We can easily check the total and free memory available at runtime using the Runtime class
You can refer to below code to check how to print the total and free memory at runtime in the console:
public class MemoryExp { public static void main(String[] args) { System.out.println("Total Memory " + Runtime.getRuntime().totalMemory()); System.out.println("Free Memory " + Runtime.getRuntime().freeMemory()); } }