Operating System - HP-UX
1833875 Members
3155 Online
110063 Solutions
New Discussion

use of memory by java on hpux

 
SOLVED
Go to solution
Shivkumar
Super Advisor

use of memory by java on hpux

Dear Sirs,

In what respect java uses memory (ram) different than other software such as c, c++ etc ?

Thanks,
Shiv
14 REPLIES 14
Bill Hassell
Honored Contributor

Re: use of memory by java on hpux

Java code doesn't use memory differently, but unlike most simple c++ programs, a lot of the library code is threaded so many subprocesses (threads) may be started. Java seems to use a lot of additional memmory, but this is generally due to Java libraries and choices made by programmers.


Bill Hassell, sysadmin
Arunvijai_4
Honored Contributor

Re: use of memory by java on hpux

Shiv, JVM uses lot of memory in any OS, you can try loading a applet in your IE and check task manager :-(. Since Java built on top of C and C++, it consumes more memory and CPU.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Arunvijai_4
Honored Contributor

Re: use of memory by java on hpux

http://www.javaworld.com/javaworld/jw-02-1998/jw-02-jperf_p.html

[ Performance tests show Java as fast as C++]

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Joseph Loo
Honored Contributor

Re: use of memory by java on hpux

hi shiv,

i like this explanation:

http://javaboutique.internet.com/articles/java_memory/

regards.
what you do not see does not mean you should not believe
Yogeeraj_1
Honored Contributor

Re: use of memory by java on hpux

hi shiv,

please allow me to add the following informations that will allow you to monitor your "java"

if you have glance plus, you can run the following:
glance -j10 -adviser_only -iterations 2 -syntax ./gln_proc_template_syntax_file


which will give you a detailed output which will look as:
# User CPU Util Cum Disk Thd
#Process Name PID PPID Pri Name ( 200% max) CPU IO Rate RSS Cnt
#------------ ------ ------ --- -------- ------------ -------- --------- ------- ---
# 10/24/05 10:27:57 C= 80 D= 9 M=100 S= 55
java 2143 1 255 root 0.0/ 0.0 394.4 0.0/ 0.0 141.3mb 10
# 10/24/05 10:28:07 C= 88 D= 10 M=100 S= 55
java 2143 1 255 root 0.0/ 0.0 394.4 0.0/ 0.0 141.3mb 10



hope this helps too!

kind regads
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Vibhor Kumar Agarwal
Esteemed Contributor

Re: use of memory by java on hpux

Java requires a bit more memory than C/C++ as its interpreted and others are compiled.

So it caches some in Ram to increase the performance. Otherwise it will become quite slow.

Vibhor Kumar Agarwal
Shivkumar
Super Advisor

Re: use of memory by java on hpux

Yogeeraj, When i executed your command i got the below error message:

Syntax file ./gln_proc_template_syntax_file is not available. Use default syntax file.

Shivkumar
Super Advisor

Re: use of memory by java on hpux

Someone told me that java uses only heap and not stack area of memory ??
RAC_1
Honored Contributor

Re: use of memory by java on hpux

You can control the java memeory usage to certain extent. When starting java, you can specify the initial heap size, maximumum heap size.

Check what your process is using.

ps -efx|grep [j]ava

java -help will give available options.
There is no substitute to HARDWORK
Yogeeraj_1
Honored Contributor

Re: use of memory by java on hpux

hi again,

sorry, you will also need the template file.

see attachment.

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Yogeeraj_1
Honored Contributor
Solution

Re: use of memory by java on hpux

hi again,

sorry, you will also need the template file.

see attachment.

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
C. Beerse_1
Regular Advisor

Re: use of memory by java on hpux

From my coding point of view, with c one can write code with the least memory usage.

C++ is a superset of c, however, there are way more functions in more libraries which use more space. Then C++ has some 4-gl and/or object-oriented features, including memory managers and garbage collectors and such. In the end, both c and C++ provide binaries that do need some libraries but that's it. The major difference will be a larger text-size for C++.

Then Java is more a 4-gl and/or object-oriented than C++, relying more on the memory management and the garbage-collector. This might result in a smaller text-size but will give a larger data-size And at run-time, java does need its virtual machine, which does occupy its resources.

So from code point of view, I see c as the most lean and clean code and java the most wastefull. However, with larger code sets, the differences will become less.

If you are willing to know, try to find something that is created in java and c/c++. Like 'hello_world.c' (just print the string "hello world" on the screen). I do know vnc (http://www.realvnc.com), that provides binary viewers for lots of platforms and also a java viewer.
make everything as simple as possible, not simpler (A.Einstein??)
Ted Buis
Honored Contributor

Re: use of memory by java on hpux

I don't believe that Java will be as fast as C or C++ in general. Data I have seen has it narrowing the gap, but I would think that a well optimized C or C++ compiler would beat Java almost always.

Memory reuse is different in Java where there is garbage collection, versus expicit control of this in C or C++. There are many debates over the merits of each approach. Well written C or C++ is likely to be better, but that assumes the code is well written.
Mom 6
Ted Buis
Honored Contributor

Re: use of memory by java on hpux