Verification Challenges

Optimize This I

Assuming a "free" statement in Java, how would you optimize the memory requirements of the following program?

 
   class L { // L is a singly linked list
     public L   n;   // next field
     public int val; // data field
   }
   class Main { // Creation and traversal of a singly-linked list
    public static void main(String args[]) {
      L x, y, t;
[1]  x = null;
[2]  while (...) { // list creation
[3]    y = new L();
[4]    y.val = ...;
[5]    y.n = x;
[6]    x = y;
      }
[7]  y = x;
[8]  while (y != null) {         // list traversal
[9]    System.out.print(y.val);
[10]   t = y.n;
[11]   y = t;
      }
    }
   }

Solution in Establishing Local Temporal Heap Safety Properties with Application to Compile-Time Memory Management,
Shaham R., Yahav E., Kolodner E.K., and Sagiv M., 
SAS 2003 [bib][abstract][ps][pdf][slides]