Alex Rivera | Logout

Why a sawtooth shaped graph?

Asked 2011-08-28T07:10:04.467
26

When I run the below mentioned code using NetBeans, the allocated heap size graph resembles a sawtooth shape. I am attaching the screen capture from JVisualVM which shows the heap allocation graph in with a sawtooth shape. The program is a simple infinite loop printing "Hello, World!" into the console.

public class HelloWorld {
    public static void main(String a[]){
        while(true) {
            System.out.println("Hello, World!");
        }
    }
}

enter image description here Can anyone explain the reason behind the shape of the graph of used heap?

PS: This happens even if I run it without using NetBeans, so it is most likely not related to NetBeans...

Edit
Report

1 Answer

1

There's lots of places it could be coming from, and it's likely implementation dependent. At least the following are possible (but are all merely speculation)

  • somewhere in the stack of streams underneath System.out.println there is a byte array allocation (given that one of the basic methods of an output stream is write(bytes []b, int off, int len))

  • it's overhead used by the monitoring software you're using (I've not used it)

  • it's overhead in the netbeans VM where it ends up showing the output

answered 2011-08-28T07:23:26.647

Your Answer