Java vs. CPU and memory

B

blackdog

Would anyone provide some information about Java with memory and CPU?

I would like to know whether Jave will consume huge amount of memory
and CPU on Sun Solaris 2.8 or Windows XP.

Your feedback will be appreciated.

Thanks.
 
O

Oliver Wong

blackdog said:
Would anyone provide some information about Java with memory and CPU?

I would like to know whether Jave will consume huge amount of memory
and CPU on Sun Solaris 2.8 or Windows XP.

Probably not, for sufficiently large values of "huge".
Your feedback will be appreciated.

Your request is too vague.

- Oliver
 
D

Daniel Dyer

Would anyone provide some information about Java with memory and CPU?

Yes, Java requires both.
I would like to know whether Jave will consume huge amount of memory
and CPU on Sun Solaris 2.8 or Windows XP.

That depends entirely on what your program does. However, Java programs
do tend to have larger memory footprints than the equivalent native
programs. This is the overhead of loading and operating the Java virtual
machine. CPU usage is likely to be less of a problem, Java performance
has improved considerably since the early days. Most types of application
work fine in Java, but without knowing what program you are talking about,
its impossible to say how it is likely to perform.

Dan.
 
B

blackdog

Daniel said:
Yes, Java requires both.


That depends entirely on what your program does. However, Java programs
do tend to have larger memory footprints than the equivalent native
programs. This is the overhead of loading and operating the Java virtual
machine. CPU usage is likely to be less of a problem, Java performance
has improved considerably since the early days. Most types of application
work fine in Java, but without knowing what program you are talking about,
its impossible to say how it is likely to perform.

Dan.


Sorry for not being clear that the message I post.
I meant to say java compare with C or C++. Does Java consume more
memory/CPU than
C or C++?

Thanks
 
R

Raymond DeCampo

blackdog said:
Sorry for not being clear that the message I post.
I meant to say java compare with C or C++. Does Java consume more
memory/CPU than
C or C++?

Java, C and C++ are programming languages. The only memory they consume
is in programmers' heads.

Programs written using Java, C and C++ consume memory when run on a
computer. In general, it is difficult to say anything of substance
about the comparative memory usage of such programs. The choice of
programmer is much more important than the choice of language in this
regard.

Ray
 
D

Daniel Dyer

Sorry for not being clear that the message I post.
I meant to say java compare with C or C++. Does Java consume more
memory/CPU than
C or C++?

The short answer is yes.

The long answer is yes but, with a few exceptions, it probably doesn't
matter.

For some tasks it is even claimed that Java can exceed C++ performance in
long-running applications because the virtual machine is able to optimise
at runtime. And, of course, many applications are I/O bound, in which
case it really doesn't matter what language you use as it will not be the
limiting factor.

Do you have an existing Java program that you want to run? Or do you want
to write a Java program to accomplish some particular task?

Dan.
 
O

Oliver Wong

blackdog said:
Sorry for not being clear that the message I post.
I meant to say java compare with C or C++. Does Java consume more
memory/CPU than
C or C++?

I'm going to do a little Q and A session myself here to spead this thread up
a bit. The conclusion is that there is no easy answer.

Q: Do Java programs consume more memory/CPU than C/C++ programs?
A: Not nescessarily. There exists Java programs which consume less memory
and CPU power than C/C++ programs. "Hello World" written in Java, for
example, consumes less memory and CPU and Doom 3 written in C++.

Q: Will a Java program consume more memory/CPU than a C/C++ program which
does the same thing?
A: Not nescessarily. I could write a really crappy implementation of "Hello
World" in C++ that requirs 2 gigs of RAM and 3 teraops to run.

Q: If you take the source code a C/C++ program, and compile it using Java,
will the resulting Java program require more memory/CPU time than its C/C++
counterpart?
A: The source code for a C/C++ program probably will not compile with a Java
compiler.

Q: If you take a C/C++ source code program, translate it to Java, will the
resulting Java program require more memory/CPU time than its C/C++
counterpart?
A: Not nescessarily, as there isn't a one-to-one mapping between C/C++
source code and Java source code. I could do a really crappy job of
translating, as above.

Q: Take two similar programs; One written in C/C++, and one written in Java.
Which one will run faster?
A: See this thread:
http://groups.google.ca/group/comp...._frm/thread/81f800895f31cdf1/cb5cfa858f8e09c5

- Oliver
 

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
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top