Announcement

Collapse
No announcement yet.

Java JDK 8 Developer Preview Released

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #11
    Originally posted by JS987 View Post
    Java isn't bad language, but memory usage of Java applications running with 64-bit Oracle JVM is ridiculous.
    Simple C++ Qt application takes less than 5 MB of private memory, but usage of similar Java application can grow up to 150 MB of private memory.
    150 MB isn't too much on machine with 4 GB or more RAM, but 10 such Java applications will use 1500 MB of private memory which is ridiculous compared to 50 MB with 10 C++ applications.
    I thought they fixed this years ago like around v1.4 or v1.5? (I'm referring to sharing common JVM libraries and classes between ten Java applications.)

    Anyway, there are ways to get around that if the programmer needs to. After all, JVMs were created even for small embedded devices where RAM is a premium.

    Comment


    • #12
      Originally posted by johnc View Post
      I thought they fixed this years ago like around v1.4 or v1.5? (I'm referring to sharing common JVM libraries and classes between ten Java applications.)
      Anyway, there are ways to get around that if the programmer needs to. After all, JVMs were created even for small embedded devices where RAM is a premium.
      jar files are mmapped, but it isn't enough as memory usage is growing from 70 MB after startup to 300 MB by clicking on parts of very simple GUI without reason.

      Comment


      • #13
        Originally posted by JS987 View Post
        jar files are mmapped, but it isn't enough as memory usage is growing from 70 MB after startup to 300 MB by clicking on parts of very simple GUI without reason.
        Well there has to be a reason.

        Comment


        • #14
          Originally posted by johnc View Post
          Well there has to be a reason.
          Some sharing doesn't work automatically. I have force it with -Xshare: on (without space). Now memory usage grows to 110 MB, which is still too much for Hello World class application.

          Comment


          • #15
            Originally posted by JS987 View Post
            Some sharing doesn't work automatically. I have force it with -Xshare: on (without space). Now memory usage grows to 110 MB, which is still too much for Hello World class application.
            Well I agree you wouldn't use Java to write a simple Hello World type application.

            But, e.g., a Java app on my Android phone doesn't use that much RAM.

            Comment


            • #16
              Originally posted by johnc View Post
              Well I agree you wouldn't use Java to write a simple Hello World type application.
              But, e.g., a Java app on my Android phone doesn't use that much RAM.
              Java on Android is probably memory optimized unlike stupid Java on Linux.

              Comment


              • #17
                one of the c# niceties I'd like to see are those async constructs. They're also available in Vala if I'm not mistaken. Microsoft forces developers to use async method calls in the RT API so that apps are more responsive. I believe it's the right decision.

                Comment


                • #18
                  Originally posted by JS987 View Post
                  Some sharing doesn't work automatically. I have force it with -Xshare: on (without space). Now memory usage grows to 110 MB, which is still too much for Hello World class application.
                  I think there is something wrong with your system. I don't see nearly that much RAM consumed.

                  Code:
                  public class HelloWorld {
                  
                      public HelloWorld () {
                          System.out.println("Hello World!");
                      }
                  
                      public static void main(final String[] args) {
                          HelloWorld hw = new HelloWorld();
                      }
                  }
                  Code:
                  <?xml version="1.0" encoding="UTF-8"?>
                  <project name="HelloWorld" default="dist" basedir=".">
                      <description>
                          Build file for the HelloWorld program.
                      </description>
                    <!-- set global properties for this build -->
                    <property name="src" value="."/>
                    <property name="build" value="build"/>
                    <property name="jarfile" value="HelloWorld.jar"/>
                  
                    <target name="dist" description="Build the Java source files, and generate the jar file." >
                      <!-- Create the necessary directory structure -->
                      <mkdir dir="${build}"/>
                      <!-- Create the time stamp -->
                      <tstamp/>
                      <!-- Compile the java code -->
                      <javac srcdir="${src}" destdir="${build}" includeantruntime="false">
                        <compilerarg value="-Xlint:unchecked,deprecation"/>
                      </javac>
                      <!-- Create the jar file -->
                      <jar jarfile="${jarfile}" basedir="${build}">
                        <manifest>
                          <attribute name="Main-Class" value="HelloWorld"/>
                        </manifest>
                      </jar>
                    </target>
                  
                    <target name="clean" description="Clean up." >
                      <!-- Delete the ${build} directory tree -->
                      <delete dir="${build}"/>
                      <delete file="${jarfile}"/>
                    </target>
                  
                  </project>
                  Code:
                  $ uname -a
                  Linux whitney 3.8.0-30-generic #44-Ubuntu SMP Thu Aug 22 20:52:24 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
                  
                  $ java -version
                  java version "1.7.0_25"
                  OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.13.04.2)
                  OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
                  
                  $ ant
                  Buildfile: build.xml
                  
                  dist:
                  
                  BUILD SUCCESSFUL
                  Total time: 0 seconds
                  
                  $ /usr/bin/time --verbose java -Xshare:on -jar HelloWorld.jar
                  Hello World!
                  	Command being timed: "java -Xshare:on -jar HelloWorld.jar"
                  	User time (seconds): 0.05
                  	System time (seconds): 0.02
                  	Percent of CPU this job got: 102%
                  	Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.07
                  	Average shared text size (kbytes): 0
                  	Average unshared data size (kbytes): 0
                  	Average stack size (kbytes): 0
                  	Average total size (kbytes): 0
                  	Maximum resident set size (kbytes): 17772
                  	Average resident set size (kbytes): 0
                  	Major (requiring I/O) page faults: 0
                  	Minor (reclaiming a frame) page faults: 5124
                  	Voluntary context switches: 75
                  	Involuntary context switches: 11
                  	Swaps: 0
                  	File system inputs: 0
                  	File system outputs: 0
                  	Socket messages sent: 0
                  	Socket messages received: 0
                  	Signals delivered: 0
                  	Page size (bytes): 4096
                  	Exit status: 0
                  Last edited by sandain; 09-11-2013, 11:56 PM.

                  Comment


                  • #19
                    Originally posted by sandain View Post
                    I think there is something wrong with your system. I don't see nearly that much RAM consumed.
                    I compared simple GUI applications, not Hello World console examples.

                    Comment


                    • #20
                      Originally posted by JS987 View Post
                      I compared simple GUI applications, not Hello World console examples.
                      Here is a Swing based Hello World then. I still don't see nearly the RAM usage that you claim.

                      Code:
                      import java.awt.BorderLayout;
                      import java.awt.event.WindowEvent;
                      import java.awt.event.WindowAdapter;
                      import javax.swing.JFrame;
                      import javax.swing.JTextArea;
                      
                      public class HelloWorld {
                      
                          public HelloWorld () {
                              JFrame gui = new JFrame();
                              JTextArea textArea = new JTextArea();
                              textArea.setColumns(20);
                              textArea.setRows(5);
                              textArea.append("Hello World");
                              gui.setTitle("Hello World");
                              gui.add(textArea, BorderLayout.CENTER);
                              gui.pack();
                              gui.addWindowListener(new WindowAdapter() {
                                  public void windowClosing(WindowEvent we) {
                                      System.exit(0);
                                  }
                              });
                              gui.setVisible(true);
                          }
                      
                          public static void main(final String[] args) {
                              HelloWorld hw = new HelloWorld();
                          }
                      }
                      Code:
                      $ /usr/bin/time --verbose java -Xshare:on -jar HelloWorld.jar
                      	Command being timed: "java -Xshare:on -jar HelloWorld.jar"
                      	User time (seconds): 0.51
                      	System time (seconds): 0.07
                      	Percent of CPU this job got: 15%
                      	Elapsed (wall clock) time (h:mm:ss or m:ss): 0:03.83
                      	Average shared text size (kbytes): 0
                      	Average unshared data size (kbytes): 0
                      	Average stack size (kbytes): 0
                      	Average total size (kbytes): 0
                      	Maximum resident set size (kbytes): 43256
                      	Average resident set size (kbytes): 0
                      	Major (requiring I/O) page faults: 0
                      	Minor (reclaiming a frame) page faults: 12993
                      	Voluntary context switches: 561
                      	Involuntary context switches: 94
                      	Swaps: 0
                      	File system inputs: 0
                      	File system outputs: 0
                      	Socket messages sent: 0
                      	Socket messages received: 0
                      	Signals delivered: 0
                      	Page size (bytes): 4096
                      	Exit status: 0

                      Comment

                      Working...
                      X