Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2006

Tip: Looking for answers? Try searching our database.

memory usage of java

Thread view: 
BB - 28 Oct 2006 14:30 GMT
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
Thomas Hawtin - 28 Oct 2006 21:24 GMT
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.