/**
  * Avoid garbage collecting interim results.
  *
  * @param value object to disable garbage collection for
  */
 private void disableCollection(IJavaObject value) {
   if (fPermStorage == null) {
     fPermStorage = new ArrayList<IJavaObject>(5);
   }
   try {
     value.disableCollection();
     fPermStorage.add(value);
   } catch (CoreException e) {
     JDIDebugPlugin.log(e);
   }
 }
 /** Re-enable garbage collection if interim results. */
 private void releaseObjects() {
   if (fPermStorage != null) {
     Iterator<IJavaObject> iterator = fPermStorage.iterator();
     while (iterator.hasNext()) {
       IJavaObject object = iterator.next();
       try {
         object.enableCollection();
       } catch (CoreException e) {
         // don't worry about GC if the VM has terminated
         if ((e.getStatus().getException() instanceof VMDisconnectedException)) {
           break;
         }
         JDIDebugPlugin.log(e);
       }
     }
     fPermStorage = null;
   }
 }
 /** @return all references to the root object as an array of IJavaObjects */
 protected synchronized IJavaObject[] getReferences() {
   try {
     int max = HeapWalkingManager.getDefault().getAllReferencesMaxCount();
     IJavaObject[] referringObjects = null;
     fIsMoreThanPreference = false;
     if (max == 0) {
       referringObjects = fRoot.getReferringObjects(max);
     } else {
       referringObjects = fRoot.getReferringObjects(max + 1);
       if (referringObjects.length > max) {
         fIsMoreThanPreference = true;
         referringObjects[max] =
             new JDIPlaceholderValue(
                 (JDIDebugTarget) fRoot.getDebugTarget(),
                 MessageFormat.format(
                     JDIDebugModelMessages.JDIReferenceListValue_9, Integer.toString(max)));
       }
     }
     return referringObjects;
   } catch (DebugException e) {
     JDIDebugPlugin.log(e);
     return new IJavaObject[0];
   }
 }