• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What exactly does Runtime.maxMemory() return?

 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm confused.

In my Java application, I use -Xms33m and -Xmx33m to set a fixed, 33-megabyte heap.

I expected that Runtime.maxMemory() and Runtime.totalMemory() would return 33 megabytes (as a long). However, I actually get 33600 kilobytes for totalMemory() and 100352 kilobytes for maxMemory().

I checked my kilobyte conversion, by looking at the values in bytes. It's OK.

I also checked that changing the -Xmx value does affect the returned value. For instance, -Xmx256m gives maxMemory() as 327680 kilobytes (and totalMemory() almost unchanged).

What is going on?
[ February 24, 2006: Message edited by: Peter Chase ]
 
Peter Chase
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, it's this bug, fixed in Java 1.4.2.

I am using 1.4.1_07
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic