- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Display the amount of free memory in the Java Virtual Machine
In order to display the amount of free memory in the Java Virtual Machine, we use the freeMemory() method. It is a method of the java.lang.Runtime Class. It returns the amount of free memory in the Java Virtual Machine. If we call the gc method, there is a possibility of increase of free memory.
Declaration − The java.lang.Runtime.freeMemory() method is declared as follows −
public long freeMemory()
Let us see a program to display the amount of free memory in the Java Virtual Machine −
Example
public class Example { public static void main(String[] args) { // print statement at the start of the program System.out.println("Start..."); // displays the free memory System.out.println("" + Runtime.getRuntime().freeMemory()); } }
Output
Start... 15732848
- Related Articles
- Display the maximum amount of memory in Java
- How to change/increase the heap size of the Java Virtual Machine in Java?
- Virtual Memory in the Operating System
- What is JVM, Java virtual machine?
- Explain Java Virtual Machine (JVM) Architecture
- What is Java Virtual Machine (JVM)?
- Java Virtual Machine (JVM) Stack Area
- How to free up the memory in JavaScript?
- Explain Java Virtual Machine's Internal Architecture
- Difference between Virtual memory and Cache memory
- Difference between Cache Memory and Virtual Memory
- What is Virtual Memory?
- What is the relationship between Address and Memory Space in a Virtual Memory System?
- How does free() know the size of memory to be deallocated?
- Why Java programs running on Android systems do not use the standard Java API and virtual machine?

Advertisements