- 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 maximum amount of memory in Java
In order to display the maximum amount of memory in Java, we use the maxMemory() method. It is a method of the java.lang.Runtime Class. It returns the maximum amount of memory that the Java Virtual Machine will try to use.
Declaration − The java.lang.Runtime.maxMemory() method is declared as follows −
public long maxMemory()
Let us see a program to display the maximum amount of memory in Java −
Example
public class Example { public static void main(String[] args) { // print statement at the start of the program System.out.println("Start..."); // displays the maximum memory System.out.println(Runtime.getRuntime().maxMemory()); } }
Output
Start... 119537664
- Related Articles
- Display the amount of free memory in the Java Virtual Machine
- Display the maximum of three integer values in Java
- Display the minimum and maximum value of primitive data types in Java
- Display Minimum and Maximum values of datatype int in Java
- Memory management in Java
- Memory leaks in Java
- Out of memory exception in Java:\n
- Display highest amount from corresponding duplicate ids in MySQL
- Java Memory Model
- Memory Consistency Error in Java
- How to display two different sums of the same price from column Amount in MySQL?
- Display the limits of DataTypes in Java
- C++ program to find maximum possible amount of allowance after playing the game
- Python – Display the key of list value with maximum range
- Java (JVM) memory model

Advertisements