• 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Releasing memory to OS

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I have an issue of System.gc() releasing memory only for the current JVM and not to the OS and hence I am getting High physical memory usage alert in my machine.
To ellaborate once the current JVM has taken up the max memory allocated for it using the command -Xmx1024m, when there is memory requirement garbage collector is releasing the memory only within the JVM and not to OS and hence the task manager is showing high usage of memory by the current JVM.Can anyone help me out in fixing this issue
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. I dont think there is any way to force the JVM to release memory to the OS.
2. If you don't want the JVM to use up to 1024m, why are you running with that parameter?
3. If the application required huge amounts of memory sometimes but can run with much less most of the time, can it be redesigned?
4. What operating system is this? How much physical memory does it have?
Bill
 
Marshal
Posts: 27288
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Windows version of Sun's JVM doesn't ever give memory back to Windows. But this is not true of all JVMs. For example IBM's JVM for the iSeries system does give back memory to the operating system. So if you can't fix the problem with your software, you could change your hardware.
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Never call System.gc(). Sun has spent millions of dollars to take memory management off the back of the programmer. Why are you trying put it back on?
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paul Clapham:
The Windows version of Sun's JVM doesn't ever give memory back to Windows.



Are you sure? I thought at least the Java 5 VM does, if it is configured correctly.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Never call System.gc().


I can't agree with that - Never is too strong. If my application has just generated a display that I know my user will take some time to absorb, it is an ideal time to call gc().
 
u johansson
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, William Brogden , you, or nobody else, should never call gc().

It's a big mistake. Sun has spent millions so you don't have to bother about memery management. Never call gc().
 
u johansson
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at this for example

http://www-128.ibm.com/developerworks/java/library/j-jtp01274.html
 
Renu Radhika
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No if I dont run with the parameter -Xmx1024 it will throw out of memory exception
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you sure it is the heap that is taking the memory?

Use a 1.5 JDK and start jconsole to see what part of the JVM is taking up the memory...
 
Paul Clapham
Marshal
Posts: 27288
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ilja Preuss:


Are you sure? I thought at least the Java 5 VM does, if it is configured correctly.

You could be right about that. I don't see any reference to it in the "new features and enhancements" document but that doesn't mean it isn't the case.
 
reply
    Bookmark Topic Watch Topic
  • New Topic