Available Memory
Last modified by Vincent Massol on 2021/03/18 11:28
Displays available memory in the JVM |
Type | Snippet |
Category | |
Developed by | |
Rating | |
License | GNU 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}}
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.