View RSS Feed


Java Performance

  1. Startup time

    by , 11-19-2011 at 07:22 PM (My Java Tips)
    Java programming language is undoubtedly one of the leading programming languages amongst new breed of programming languages. Though it is considered to be the best in the industry, it too has its own limitations, flaws due to certain unavoidable programming constraints which Java follows.

    Execution of Java program is said to be slow and it requires more memory when compared with programming languages such as C, C++ etc. Programs written in C, C++ are natively compiled, where as Java ...
  2. Performance issues related to trigonometric functions , floating point arithmetic and

    by , 11-19-2011 at 07:19 PM (My Java Tips)
    I have briefly listed the performance issues related to trigonometric functions, floating point arithmetic functions and Java Native Interface. I hope these will be helpful.

    Trigonometric functions

    In Java, results got from trigonometric functions and calculations may not be as accurate as that of results got from trigonometric functions and calculations of C language. This is because because Java has strict specifications for the results of mathematical operations.This ...
  3. Performance issues related to Look and Feel of GUI

    by , 11-19-2011 at 07:15 PM (My Java Tips)
    When you use Java Swing or Java Foundation Classes (JFC) for your GUI application development the look and feel of GUI application is not the same as the look and feel of your operating system as JFC or Java Swing has its own built in look and feel. Although, if you want you can achieve the same look and feel as of your operating system's by using Java's Abstract Window Toolkit (AWT), the AWT toolkit is unable to meet advanced GUI programming requirement.

    The Java Foundation Classes ...
    Tags: awt, java swing, jfc, swt Add / Edit Tags
  4. Java performance Issues

    by , 11-16-2011 at 08:17 PM (My Java Tips)
    In this post, I will talk about Java performance Issues briefly.


    The output of a Java compiler is a bytecode and not an executable code. The Java Virtual Machine (JVM) interprets the Java bytecode at runtime. Most of the modern programming languages such as C, C++ are not interpreted and compiled to the executable code because of the performance concern. When a program is interpreted, it generally executes slowly when compared with an executable code.
  5. Vector Capacity

    by , 11-13-2011 at 12:48 PM (My Java Tips)
    In this post, I will talk about the performance issues related to vector capacity. I have noticed, that normally developers donít care about the performance issues and declare the vector as:

    Java Code:
    Vector vector = new Vector();

    Newly created vector has no element in it so its size is 0 but its capacity is 10 by default. So if you donít specify the capacity of the vector (and call the default constructor), its capacity will be 10. Capacity of the vector is the ...
    Tags: capacity, vector Add / Edit Tags
  6. Performance Issues (String Concatenation)

    by , 11-09-2011 at 05:55 PM (My Java Tips)
    String concatenation is a task that is overlooked by the programmers. In this post, I will write about the performance issues related to string concatenation.

    Strings are immutable objects and to concatenate strings, java has to perform a lot of operations in the background. Consider the following code segment:

    Java Code:
    String a=  "a";
    String b=  "b";
    String str = a + b;
    This is compiled to

    Java Code:
  7. Performance Issues (StringTokenizer)

    by , 11-09-2011 at 05:46 PM (My Java Tips)
    StringTokenizer is a very useful class that is used by developers while parsing text. It works fine and produces the required results.

    Java Code:
    StringTokenizer st = new StringTokenizer(s,",");

    StringTokenizer is very powerful and can handle large sets of delimiters at once. This makes it powerful but a little slow. What if we have a single character delimiter? Should we still use StringTokenizer? If we want to make life easy, the answer is yes. But ...
  8. Performance Issues (adding element to a Vector)

    by , 11-09-2011 at 05:43 PM (My Java Tips)
    Adding elements to a Vector is a normal practice but there are few performance issues related to this which should be considered.

    Elements can be added to Vector using any of the following:

    - insertElementAt(e, index)
    - addElement(e)
    - add(e)
    - add(index,e)

    The addElement(e) and add(e) methods are used to add elements at the end of Vector whereas insertElementAt(e, index) and add(index, e) methods are used to insert element at any ...
  9. Java built-in data types (performance issues)

    by , 11-06-2011 at 06:29 PM (My Java Tips)
    Java built in data types provide programmers ease of storing their required data in appropriate data type. But in come cases, it may become a bottleneck. When doing low level related work, the speed is very important. In such case don't use the Java built-in data types.

    Lets take an example. If you are using an Integer class, just think of all the overhead you are creating by using the wrapper class. One rule of thumb is to use the primitives instead of wrapper. This ...
  10. Java IO tasks

    by , 11-01-2011 at 06:28 PM (My Java Tips)
    IO is always a performance issue. I will write about this in this post.

    IO is a performance issue but now its really simple and efficient to do IO related tasks. Always use buffering if you need performance. Because if you directly use FileInputStream, JVM is going to issue file read system call everytime you read a byte of data. In case of buffering, whole buffer is read in one go and only if there's no data in the buffer, JVM issues a system call to read the disk.
    Java SE , Performance
  11. Avoiding null pointer exception

    by , 11-01-2011 at 06:26 PM (My Java Tips)
    One should try avoiding null pointer exception. In case of coding an application that needs high degree of reliability, don't take risks. I will present an example.

    Check the following piece of code.

    Java Code:
    private boolean isNullString(String string) {
    return (string.equals(""));
    It seems a normal piece of code. But still there's a hidden trap here. What is the string which is passed is null? So try to rephrase ...
    Java SE , Performance
  12. Memory Leaks

    by , 05-25-2011 at 11:04 AM (My Java Tips)
    You are aware of the fact that garbage collection collects and removes all the unwanted objects from memory without used intervention. But sometimes, you run into memory leaks problems that demands investigation. I will shed some light on this issue in the next few posts.

    The Java GC process is a low-priority thread and it constantly searches memory for unreachable objects that are not reachable by any live thread. Different JVMs use different algorithms to determine how to collect ...
  13. Javap

    by , 05-24-2011 at 02:58 PM (My Java Tips)
    Javap is shiped with JDK and it really very useful when you want to see what your compiler is doing to your code. It generates source code from a compiled class file.

    Javap is a utility provided in Java Development Kit (JDK) that can be used to improve source code. this is done by generating source code from compiled code and seeing how our code was treated by the Compiler. Later code improvements can be made.

    A very interesting example can be to see how source code ...
  14. Final keyword improves performance

    by , 05-21-2011 at 11:10 PM (My Java Tips)
    Its right to say that final keyword improves performance. For example, if you declare a method as final, then you cannot override it in derived classes. When this is told to compiler in advance using final keyword, it improves performance.

    Java Code:
    public final void doSomethng()
    Knowing that a method cannot be overridden, complier inline that method into its derived classes.
    Final variables, especially static final variables, ...
    Tags: final Add / Edit Tags