user2824073
user2824073

Reputation: 2485

Calculate amount of available heap memory in Java

I have the following details of a Java process (WildFly application server):

 "heap-memory-usage" => {
            "init" => 536870912L,
            "used" => 73683328L,
            "committed" => 505413632L,
            "max" => 1908932608L
        }

I need to create an alert when the amount of free memory drops under a certain level. Is it correct to assume that the heap available memory equals to (max - used) ? or should I use (max - committed) ?
Thanks

Upvotes: 0

Views: 380

Answers (1)

Evgeniy Dorofeev
Evgeniy Dorofeev

Reputation: 136112

You should use max - used. See java.lang.management.MemoryUsage class API for details

Upvotes: 1

Related Questions