Available Memory

Last modified by Vincent Massol on 2021/03/18 11:28

cogDisplays available memory in the JVM
TypeSnippet
Category
Developed by

Vincent Massol

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1

Table of contents

Description

Sometimes you wish to see how much memory the JVM really has. To do so, you can copy this code in any wiki page to execute it:

{{groovy}}
println "Current size of heap in bytes: ${Runtime.getRuntime().totalMemory()}"
println "Maximum size of heap in bytes. ${Runtime.getRuntime().maxMemory()}"
println "Amount of free memory within the heap in bytes: ${Runtime.getRuntime().freeMemory()}"
{{/groovy}}

For more thorough information about the JVM see Accessing JVM information using JMX.

Get Connected