This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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
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
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.
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.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Author and all-around good cowpoke
Joined: Mar 22, 2000
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().
Joined: Dec 27, 2005
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().