[olug] understanding Linux memory usage

Ryan Stille ryan at cfwebtools.com
Thu Feb 21 16:23:00 UTC 2008


Christopher Cashell wrote:
> When the JVM starts up, it is reserving enough memory for all of the
> libraries it thinks it will need.  It also reserves memory for it's
> heap, as specified.  However, when it does that, the kernel is giving
> it a pointer to this memory address space, but internally, it will
> allocate that memory as needed.  Because the memory isn't actually in
> use, just reserved, it doesn't show up as used memory.
>
> Once the application actually makes use of the memory, it will start
> to show up in top and ps as being taken by the application.
>   

Ok, so doesn't this make the output of "free" and the free value shown 
in the top command *worthless*?  It may say you have 2GB free, so you 
think that server is running fine and could handle an additional task or 
something, but really that 2GB might be allocated to other processes 
that just haven't used the memory yet?

If this is the case, are there any better tools for watching memory 
usage on a Linux box?  On windows, I just right click on my task bar and 
select Task Manger, and it tells me everything I could want to know.
> Setting the max memory isn't a bad idea, to prevent the application
> from going crazy.  Setting the minimum is rarely a good idea, in my
> experience.  It limits the amount of memory anything else on the box
> can potentially allocate, even though Java may not be using it.  Also,
> if you do end up with other programs on the box requesting memory,
> it's possible for Linux to start killing processes as OOM, even though
> it isn't actually out of memory, it's just that all of the memory is
> reserved (even though it may not be used).  Your java program could
> even end up getting killed that way.
>
>   

The sole purpose of this this server is run this java app, so I want it 
to be able to get all the memory it can.  Also I thought there was some 
kind of performance increase my having it grab all the memory at once, 
instead of having it work its way up to the max amount as it needs it.

Travis Owens wrote:
> Another thing you may want to do with your Java applications is deploy them
> using the Sun JDK 1.5+. This will allow you to take advantage of the JMX
> reporting tools, and using jconsole (or even rolling your own application to
> report) you can monitor each application from the JVM directly. You'll see
> thread count, memory usages, etc...
> (used exhaustively at my work -- unfortunately, I'm not a Java developer,
> merely a sys-admin)
Yes I discovered this yesterday.  I installed the JDK on my desktop 
(which gave me jconsole.exe), then added a few switches to my jvm start 
up script. Then I was able to connect and watch memory usage.  Very cool.

Thanks,
-Ryan




More information about the OLUG mailing list