Heteroclinic.net logo

www.heteroclinic.net

Java Virtual Machine Mememory Management Excercise I
Creating an OutOfMemoryError - Introduction

20141231

A spectre is haunting the log. The spectre of NullPointerException.
In this excercise, we experiment, with given VM settings, we want to observe how the VM behaves when the heap is used up and a 'new' operation is submitted.

Java Virtual Machine Mememory Management Excercise I
Creating an OutOfMemoryError - Code Snippet

20141231

We attach the following code snippet. The purpose is stash some objects in a container without dereference them. Thus it creates painful JVM GC effort. As you programmed with c/C++ before, malloc failure will return NULL. This is not the case here -- we counted zero 'null's and the VM halted with an OutOfMemoryError.


Java Virtual Machine Mememory Management Excercise I
Creating an OutOfMemoryError - Data Gathering

20141231

I would prefer use log file to trace critical information. I use the following shell commands. Please refer to Oracle orginal document about the JVM parameters. Java 8 and Java 7 vms demonstrate consistent behavior to our program.



The following is the data gathered in our experiment:



Java Virtual Machine Mememory Management Excercise I
Creating an OutOfMemoryError - Discussion

20141231

This excercise roots from the c malloc returning NULL upon failure. It is interesting and a littble bit surprising. Such thing did not come with a flat curve search and gratification didactic, so I bothered a little bit to write this excercise. Though we did not conclude the NPE is the targeting finger to 'new', we can conclude that engineering should use whitebox so the test cases would be finite. Blackbox is blackbox, it may be variant or full of suprises, never test never know, inconsistent results etc. Nor do we aim to compare languages, like comparing shopping and jogging -- they serve different purposes.