public void trim(){
         // triming is expensive. to avoid cases where we repeatedly trim
         // a very small amount of storage, we only trim if the buffer
         // has a non-trivial block of empty space.
         if(nPointsInBuffer>0 && nPointsAllocated-nPointsInBuffer>=32){
             float   px[], py[];
             double  t[];
             int     i;

             nPointsAllocated = nPointsInBuffer;

             px = new float[nPointsInBuffer];
             for(i=0; i<nPointsInBuffer; i++)
                px[i] = x[i];
             x  = px;
             px = null;  // done to enable garbage collection ASAP.

             py = new float[nPointsInBuffer];
             for(i=0; i<nPointsInBuffer; i++)
                py[i] = y[i];
             y  = py;
             py = null;

             t = new double[nPointsInBuffer];
             for(i=0; i<nPointsInBuffer; i++)
                t[i] = time[i];
             time = t;
             t = null;
          }
       }