File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Releasing memory to OS

 
Renu Radhika
Ranch Hand
Posts: 243
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13045
6
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Paul Clapham
Sheriff
Pie
Posts: 20185
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
u johansson
Ranch Hand
Posts: 47
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • 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
Rancher
Posts: 13045
6
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No if I dont run with the parameter -Xmx1024 it will throw out of memory exception
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Pie
Posts: 20185
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic