memory usage of java

B

BB

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
comweb 20692 0.0 0.0 5860 1240 ? S 15:23 0:00 sshd:
comweb@pts/2
comweb 20693 0.0 0.0 4056 1756 pts/2 S 15:23 0:00 \_ -bash
comweb 21246 0.0 0.0 2332 708 pts/2 R 15:26 0:00 \_ ps
uxf
comweb 20059 0.0 0.5 207108 10752 ? S Oct26 0:00
/usr/local/jdk/bin/java MiniChatServer
comweb 20060 0.0 0.5 207108 10752 ? S Oct26 0:00 \_
/usr/local/jdk/bin/java MiniChatServer
comweb 20061 0.0 0.5 207108 10752 ? S Oct26 0:00 \_
/usr/local/jdk/bin/java MiniChatServer
comweb 20062 0.0 0.5 207108 10752 ? S Oct26 0:00 \_
/usr/local/jdk/bin/java MiniChatServer
comweb 20063 0.0 0.5 207108 10752 ? S Oct26 0:00 \_
/usr/local/jdk/bin/java MiniChatServer
comweb 20064 0.0 0.5 207108 10752 ? S Oct26 0:06 \_
/usr/local/jdk/bin/java MiniChatServer
comweb 20065 0.0 0.5 207108 10752 ? S Oct26 0:00 \_
/usr/local/jdk/bin/java MiniChatServer
comweb 20066 0.0 0.5 207108 10752 ? S Oct26 0:00 \_
/usr/local/jdk/bin/java MiniChatServer
comweb 20067 0.0 0.5 207108 10752 ? S Oct26 0:00 \_
/usr/local/jdk/bin/java MiniChatServer
comweb 20072 0.0 0.5 207108 10752 ? S Oct26 0:00 \_
/usr/local/jdk/bin/java MiniChatServer
comweb 20073 0.0 0.5 207108 10752 ? S Oct26 0:00 \_
/usr/local/jdk/bin/java MiniChatServer
comweb 20074 0.0 0.5 207108 10752 ? S Oct26 0:00 \_
/usr/local/jdk/bin/java MiniChatServer
comweb 18782 0.0 0.5 207108 10752 ? S 15:19 0:00 \_
/usr/local/jdk/bin/java MiniChatServer

I have some consern about the memory usage of java.
above is what the comand ps uxf gives.

Does it mean that my application uses 13 * 0.5% = 6.5% of the system memory
?
Or only 0.5% of the systems memory.

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 ?

So small chat uses 0.5% of 2 GB = at least 10Mb of memory!!
Correct ?

/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)

Thanks for any comments
Rob
 
T

Thomas Hawtin

BB said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top