Chris Kimpton
Chris Kimpton

Reputation: 5541

In Java, Runtime.getRuntime.freeMemory() occasionally returns a negative number - why?

In Java, Runtime.getRuntime.freeMemory() occasionally returns a negative number - why?

It possibly seems to happen more with busy/memory gobbling code.

This must have been answered elsewhere, but my searching-fu is failing me.

I am running with Oracle Windows 64bit JVM - 1.7.0_80. Also see this with the OpenJDK, Linux version - 1.7.0_85 (64bit) - although as I watch it now, its negative for the maxMemory and totalMemory calls - freeMemory is positive.

Using ParNew/ConcurrentMarkSweep garbage collectors.

Upvotes: 2

Views: 815

Answers (1)

Chris Kimpton
Chris Kimpton

Reputation: 5541

Whoops - this is a bit embarrassing.

I was monitoring it via a tool that was holding the numbers as INT - hence large numbers were wrapping/going negative :(

Apologies for wasting your time :(

Upvotes: 1

Related Questions