Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

-TheDragon

Java; am I missing something?

This topic is 6112 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve been reading up on java and have started learning to program with it a bit using Forte''s IDE, but I have a general question to anyone knowledgebale about java in a system intensive environment. After developing any application or using any java app (even small stuff, very small, 100k) a javaw process opens that''s ~15MB to start with and gets larger with the larger app I run. I''m assuming that its the virtual machine that came with windows XP (its in system32/, if WindowsXP doesn''t come with one then Sun''s java SDK probably put it there). Anyway, I was wondering, does the virtual machine have to run everytime the app is run? It''s a huge memory hog and makes small apps in java not a viable process. If I wanted to program a small calculator that I could easily distribute, would I have to distribute a virtual machine with it? If the user had a virtual machine already, would it immediatley gulp 15MB of memory as soon as the user runs the program? I was looking at a PHP IDE suite, and their windows shortcut is my virtual machine (C:\WINDOWS\system32\javaw.exe) with a path argument on the end of it. I thought that interesting, not sure hwo they determined where my virtual machine was. Anyway, the IDE runs the virtual machine, and because of that (or I believe because of that) its huge in memory. 40MB+. Is there a more practical, memory conservative way to run/distribute java apps? Am I missing something? -Phil Crosby www.philisoft.com www.graphics-design.com

Share this post


Link to post
Share on other sites
Advertisement
Yes, any Java program needs a virtual machine in order for it to run. If you distribute a Java program, you also need to make sure that the JRE (Java Runtime Environment) is installed on the machine. The JRE contains Sun''s virtual machine and other things that are needed for Java apps to run. Note that the JDK comes with the JRE, along with all the libraries that you need to develop a Java program. The JRE does not contain the necessary items for development. It is for running Java applications only. The virtual machine is a hog; welcome to the world of Java programming. If you don''t like it, use C++ :-).

Share this post


Link to post
Share on other sites
When running a standard Java application it is absolutely necessary to have a Java VM running as well (this is what processes the java bytecode that javac produces and actually executes the application).
It is, however, possible to compile java-programs into standard executables that can run without the VM. You will need a platform-specific compiler, and the resulting application will also be platform-specifec.
Not only will doing this result in a smaller memory-footprint, but the application will also run faster.
For a little more information on how to do this, point your browser at:
http://www.javaworld.com/javaworld/javaqa/2000-06/02-qa-0609-exe.html

-Neophyte

- Death awaits you all with nasty, big, pointy teeth. -

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Staticly compiling Java programs into executables will generally not make your programs faster. I hear IBM even abandoned their static compilation strategies in favour of dynamic JIT compilation for performance reasons and I have yet to see any static Java compiler do well in benchmarks.

RAM footprint depends largely on the JVM and while I have personally never had any reason to profile it, I have heard people quote numbers at around 8-12 Mb as typical footprints for Sun''s JDKs in posts at javagaming.org and that JDK1.4, that is in beta3 now, can shrink itself a lot more (~2Mb). Those numbers depend on the app that you are running though. Anyone know a simple way to measure the memory consumption of a process on Win98?

Henry

Share this post


Link to post
Share on other sites
Actually, statically compiling a Java program doesn''t solve anything. In fact, it makes things a lot worse. Instead of distributing a JRE (which is about 5 MB), you''ll end up distributing a few DLLs one of which weighs in at 9MB!! Memory consumption also increases about 20%. To see this for yourself, get Excelsior-JET. It is free for personal use. I tried them on the demos that came with the JDK and I wasn''t impressed at all. I haven''t tried the other static compilers, but seeing at Excelsior is among the most popular, I''m assuming that the rest are the same.

As for your very large app, depends entirely on what you''re doing. JavaTM Platform Performance is a very good book to read. Java is a real pain in this respect. Its really hard to optimize for memory footprint.

Share this post


Link to post
Share on other sites
Lol how can they go from a memory footprint of ~14MB to ~2MB with JDK1.4? THat would be quite amazing, and actually required to gain my support for this language. I know technically it is well developed and good for low development times, and organized, but I cannot use it on a practical level unless that memory footprint is a lot smaller. Platform independecy though would be quite excellent. sun.java.com is only offering JDK1.1 for download; is there a general idea when 1.4 is to be released? Or, a better place to find info on it than sun''s site?

THanks for all those who replied, every single post above mine was helpful. Also, I took a look at that JavaTM Platform Performance book, and it was quite excellent (the parts that I read). He showed a spec sheet for sizes of objects in jdk1.22 and 1.3, and how optimizations in the virtual machine made a huge difference. I''m not too concerned about object optimizations in ram _yet_, because I wanted to check out memory usage initially before delving into this language (my hello world program was 10MB.. ack)

-Phil Crosby
www.philisoft.com
www.graphics-design.com

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Here is a page with various JDK downloads: http://java.sun.com/j2se/

Henry

Share this post


Link to post
Share on other sites
quote:
Original post by -TheDragon
I was looking at a PHP IDE suite, and their windows shortcut is my virtual machine (C:\WINDOWS\system32\javaw.exe) with a path argument on the end of it. I thought that interesting, not sure hwo they determined where my virtual machine was. Anyway, the IDE runs the virtual machine, and because of that (or I believe because of that) its huge in memory. 40MB+. Is there a more practical, memory conservative way to run/distribute java apps? Am I missing something?

-Phil Crosby
www.philisoft.com
www.graphics-design.com


If I''m right, you''re talking about Zend IDE( which is the only Java based PHP editor that I know of, then again, there might be other but what the hey! ). Now, if you''re talking about Zend IDE, you have to tell yourself one thing, this program is pretty big... As for the question about distributing the VM, no you don''t as most OS have it already or if it doesn''t it''s up to the client to get a java runtime environment. Since there are 2 different runtime environment for Java, IBM and SUN, it''s up to them to decide which one they want to use. For instance, Zend IDE is made using the IBM Java SDK and on my system, it runs using SUNs Java SDK.



"And that''s the bottom line cause I said so!"

** I WANT TO BE THE MODERATOR FOR THE LINUX FORUM **

Cyberdrek

Resist Windows XP''s Invasive Production Activation Technology!

"gitty up" -- Kramer
/(bb|[^b]{2})/ that is the Question -- ThinkGeek.com
Hash Bang Slash bin Slash Bash -- #!/bin/bash

Share this post


Link to post
Share on other sites
quote:
Original post by -TheDragon
Lol how can they go from a memory footprint of ~14MB to ~2MB with JDK1.4? THat would be quite amazing, and actually required to gain my support for this language. I know technically it is well developed and good for low development times, and organized, but I cannot use it on a practical level unless that memory footprint is a lot smaller. Platform independecy though would be quite excellent. sun.java.com is only offering JDK1.1 for download; is there a general idea when 1.4 is to be released? Or, a better place to find info on it than sun''s site?

THanks for all those who replied, every single post above mine was helpful. Also, I took a look at that JavaTM Platform Performance book, and it was quite excellent (the parts that I read). He showed a spec sheet for sizes of objects in jdk1.22 and 1.3, and how optimizations in the virtual machine made a huge difference. I''m not too concerned about object optimizations in ram _yet_, because I wanted to check out memory usage initially before delving into this language (my hello world program was 10MB.. ack)

-Phil Crosby
www.philisoft.com
www.graphics-design.com


Wrong dude, I downloaded the JDK1.3 from there a while back... Go back and don''t be afraid to browse...



"And that''s the bottom line cause I said so!"

** I WANT TO BE THE MODERATOR FOR THE LINUX FORUM **

Cyberdrek

Resist Windows XP''s Invasive Production Activation Technology!

"gitty up" -- Kramer
/(bb|[^b]{2})/ that is the Question -- ThinkGeek.com
Hash Bang Slash bin Slash Bash -- #!/bin/bash

Share this post


Link to post
Share on other sites
My mistake all, the 1.4beta3 SDK installs the 1.4 virtual machine as well. Found that out after I installed the JRE from sun. So, I suppose I''ve had 1.4 all along; works great, still huge in memory tho. The "java webstart" program, a small little launcher app, takes 17MB under XP. I''ll be taking java classes in college next semester, so I''ll see what other solutions there are and what I can do with this language =) Thanks to all who posted!

-Phil Crosby
www.philisoft.com
www.graphics-design.com

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!