[olug] Re: OJUG Re: Commanding java_vm to give memory back to the OS?

Rob Townley rob.townley at gmail.com
Sat Jan 28 17:42:41 UTC 2006


Matt,

thanks for the Xms tip, after doing various searches for Xms, i also
found Xmx, which sets the maximum size.  I tried setting the following
"-Xms8M -Xmx64M" parameters in the ./ControlPanel, thinking this would
set the minimum size to 8M and the max to 64M.  I rebooted.  The
java_vm memory usage has not changed, still using 270MB.

JRE	1.5.0_06	/usr/lib/j2se/jre1.5.0_06	-Xms8M -Xmx64M

I guess the next step is to figure out how to prints out the command
line parameters to verify whether or not the XMS and XMX parameters
are actually seen.


On 1/25/06, Matt Secoske <secoskem at gmail.com> wrote:
> To see what the JVM thinks is free or total memory, look at the
> java.lang.Runtime javadocs  for the freeMemory() and totalMemory() methods.
> The only thing you can do to free up memory is to call Runtime.gc().
> Unfortunately this will run at its discretion, and may or maynot (or
> both!!!) free up memory.
>
> You may also want to lower the minimum amount of memory the JVM holds: when
> starting the JVM pass it the -XMS parameter with a value of, say 16M (for 16
> megabytes).  (i.e.  java -XMS16M matt.MyClass)
>
> There are some other command line options to reduce memory/control the
> garbage collector... overall its best to leave those alone unless you know
> exactly what you are doing.
>
> - Matt
>
> On 1/25/06, Rob Townley <rob.townley at gmail.com> wrote:
> >
> >    According to the "KDE System Guard" process list, my java_vm is
> > using 276MegaBytes of memory.  I only have 256MB of physical ram, so
> > my harddrive is swapping like crazy and wasting battery life.  I
> > opened the java console and ran garbage collection, but the console
> > says java is using less than 4MB of RAM.   I know for certain, that
> > there are no Java applets running, so it should be using zero.  How
> > can i command JAVA to give the memory back to the operating system
> > that it is not using?
> >
> >   At one time, there was NOT a standard C function to actually tell
> > the C runtime to give the memory back to the OS.  The C runtime would
> > keep the memory even though you had freed it.  But some operating
> > systems have a  non standard call to free the memory.
> >
> > 256MB RAM
> > Java 1.5
> > FireFox 1.5
> > Debian Linux with 2.6 Kernel
> >
>
>
>
> --
> Matt Secoske
>  http://www.secosoft.net



More information about the OLUG mailing list