Re: memory usage of java
BB wrote:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
comweb 20059 0.0 0.5 207108 10752 ? S Oct26 0:00
/usr/local/jdk/bin/java MiniChatServer
Does it mean that my application uses 13 * 0.5% = 6.5% of the system memory
?
Or only 0.5% of the systems memory.
This sor of stuff is highly misleading. Windows will be leading is
subtly different ways.
At a guess you are using a pre-2.6 kernel version of Linux. It reports
threads individually. Each thread has access to the same address space.
So for 13 threads the same memory is reported 13 times over. If you have
10,000 threads, it'll be a mess.
If I remember this all correctly, in your example you have a process
using 0.5% of physical memory (%MEM), around half of its address space
(assuming a 32-bit OS) and 10 MB of physical memory.
Again you have a problem with counting the same memory multiple times. A
shared library or memory mapped file will but only be loaded into
physical memory once, but be counted to all processes using it.
Also if you start using your other 99.5% of physical memory, some of the
process may get swapped out. That has probably happened.
Command top gives this line
Mem: 2074312k total, 1958364k used, 115948k free, 57720k buffers
Swap: 2008116k total, 64480k used, 1943636k free, 972828k cached
So a system with 2 Gb of real memory ?
correct ?
Looks like it.
So small chat uses 0.5% of 2 GB = at least 10Mb of memory!!
Correct ?
Yup, but when in use it'll probably be using somewhat more than that.
Although some of that may be shared with other processes. Adding
additional threads does not take up much physical memory (although you
can exhaust address space first).
/usr/local/jdk/bin/java -version
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)
Even in the 1.4 series, 1.4.2 came out a long time ago.
Tom Hawtin