Index: src/java/net/percederberg/mibble/MibTypeSymbol.java
===================================================================
--- src/java/net/percederberg/mibble/MibTypeSymbol.java	(revision 190)
+++ src/java/net/percederberg/mibble/MibTypeSymbol.java	(working copy)
@@ -16,7 +16,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  *
- * Copyright (c) 2004-2005 Per Cederberg. All rights reserved.
+ * Copyright (c) 2004-2006 Per Cederberg. All rights reserved.
  */
 
 package net.percederberg.mibble;
@@ -26,7 +26,7 @@
  * type assignment, i.e. a defined type name.
  *
  * @author   Per Cederberg, <per at percederberg dot net>
- * @version  2.6
+ * @version  2.7
  * @since    2.0
  */
 public class MibTypeSymbol extends MibSymbol {
@@ -81,6 +81,16 @@
     }
 
     /**
+     * Clears and prepares this MIB symbol for garbage collection.
+     * This method will recursively clear any associated types or
+     * values, making sure that no data structures references this
+     * symbol.
+     */
+    void clear() {
+        type = null;
+    }
+
+    /**
      * Returns the symbol type.
      *
      * @return the symbol type
Index: src/java/net/percederberg/mibble/MibValue.java
===================================================================
--- src/java/net/percederberg/mibble/MibValue.java	(revision 190)
+++ src/java/net/percederberg/mibble/MibValue.java	(working copy)
@@ -16,7 +16,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  *
- * Copyright (c) 2004-2005 Per Cederberg. All rights reserved.
+ * Copyright (c) 2004-2006 Per Cederberg. All rights reserved.
  */
 
 package net.percederberg.mibble;
@@ -28,7 +28,7 @@
  * be used.
  *
  * @author   Per Cederberg, <per at percederberg dot net>
- * @version  2.6
+ * @version  2.7
  * @since    2.0
  */
 public abstract class MibValue implements Comparable {
@@ -97,6 +97,18 @@
     }
 
     /**
+     * Clears and prepares this value for garbage collection. This
+     * method will recursively clear any associated types or values,
+     * making sure that no data structures references this object.<p>
+     *
+     * <strong>NOTE:</strong> This is an internal method that should
+     * only be called by the MIB loader.
+     */
+    protected void clear() {
+        reference = null;
+    }
+
+    /**
      * Checks if this value referenced the specified value symbol.
      *
      * @param name           the value symbol name
Index: src/java/net/percederberg/mibble/Mib.java
===================================================================
--- src/java/net/percederberg/mibble/Mib.java	(revision 190)
+++ src/java/net/percederberg/mibble/Mib.java	(working copy)
@@ -16,7 +16,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  *
- * Copyright (c) 2004-2005 Per Cederberg. All rights reserved.
+ * Copyright (c) 2004-2006 Per Cederberg. All rights reserved.
  */
 
 package net.percederberg.mibble;
@@ -37,7 +37,7 @@
  * {@link MibLoader MIB loader}.
  *
  * @author   Per Cederberg, <per at percederberg dot net>
- * @version  2.6
+ * @version  2.7
  * @since    2.0
  *
  * @see <a href="http://www.ietf.org/rfc/rfc3411.txt">RFC 3411 - An
@@ -198,6 +198,37 @@
     }
 
     /**
+     * Clears and prepares this MIB for garbage collection. This method
+     * will recursively clear all associated symbols, making sure that
+     * no data structures references symbols from this MIB. Obviously,
+     * this method shouldn't be called unless all dependant MIBs have
+     * been cleared first.
+     */
+    void clear() {
+        loader = null;
+        log = null;
+        if (imports != null) {
+            imports.clear();
+        }
+        imports = null;
+        if (symbolList != null) {
+            for (int i = 0; i < symbolList.size(); i++) {
+                ((MibSymbol) symbolList.get(i)).clear();
+            }
+            symbolList.clear();
+        }
+        symbolList = null;
+        if (symbolNameMap != null) {
+            symbolNameMap.clear();
+        }
+        symbolNameMap = null;
+        if (symbolValueMap != null) {
+            symbolValueMap.clear();
+        }
+        symbolValueMap = null;
+    }
+
+    /**
      * Compares this MIB to another object. This method will return
      * true if the object is a string containing the MIB name, a file
      * containing the MIB file, or a Mib having the same name.
Index: src/java/net/percederberg/mibble/MibMacroSymbol.java
===================================================================
--- src/java/net/percederberg/mibble/MibMacroSymbol.java	(revision 190)
+++ src/java/net/percederberg/mibble/MibMacroSymbol.java	(working copy)
@@ -16,7 +16,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  *
- * Copyright (c) 2005 Per Cederberg. All rights reserved.
+ * Copyright (c) 2005-2006 Per Cederberg. All rights reserved.
  */
 
 package net.percederberg.mibble;
@@ -26,7 +26,7 @@
  * macro definition, i.e. a defined macro name.
  *
  * @author   Per Cederberg, <per at percederberg dot net>
- * @version  2.6
+ * @version  2.7
  * @since    2.6
  */
 public class MibMacroSymbol extends MibSymbol {
@@ -61,6 +61,16 @@
     }
 
     /**
+     * Clears and prepares this MIB symbol for garbage collection.
+     * This method will recursively clear any associated types or
+     * values, making sure that no data structures references this
+     * symbol.
+     */
+    void clear() {
+        // Nothing to clear
+    }
+
+    /**
      * Returns a string representation of this object.
      *
      * @return a string representation of this object
Index: src/java/net/percederberg/mibble/MibValueSymbol.java
===================================================================
--- src/java/net/percederberg/mibble/MibValueSymbol.java	(revision 190)
+++ src/java/net/percederberg/mibble/MibValueSymbol.java	(working copy)
@@ -16,7 +16,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  *
- * Copyright (c) 2004-2005 Per Cederberg. All rights reserved.
+ * Copyright (c) 2004-2006 Per Cederberg. All rights reserved.
  */
 
 package net.percederberg.mibble;
@@ -32,7 +32,7 @@
  * an object identifier.
  *
  * @author   Per Cederberg, <per at percederberg dot net>
- * @version  2.6
+ * @version  2.7
  * @since    2.0
  */
 public class MibValueSymbol extends MibSymbol {
@@ -118,6 +118,20 @@
     }
 
     /**
+     * Clears and prepares this MIB symbol for garbage collection.
+     * This method will recursively clear any associated types or
+     * values, making sure that no data structures references this
+     * symbol.
+     */
+    void clear() {
+        type = null;
+        if (value != null) {
+            value.clear();
+        }
+        value = null;
+    }
+
+    /**
      * Checks if this symbol corresponds to a scalar. A symbol is
      * considered a scalar if it has an SnmpObjectType type and does
      * not represent or reside within a table.
Index: src/java/net/percederberg/mibble/value/ObjectIdentifierValue.java
===================================================================
--- src/java/net/percederberg/mibble/value/ObjectIdentifierValue.java	(revision 192)
+++ src/java/net/percederberg/mibble/value/ObjectIdentifierValue.java	(working copy)
@@ -16,7 +16,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  *
- * Copyright (c) 2004-2005 Per Cederberg. All rights reserved.
+ * Copyright (c) 2004-2006 Per Cederberg. All rights reserved.
  */
 
 package net.percederberg.mibble.value;
@@ -34,7 +34,7 @@
  * identifier values in a tree hierarchy.
  *
  * @author   Per Cederberg, <per at percederberg dot net>
- * @version  2.6
+ * @version  2.7
  * @since    2.0
  */
 public class ObjectIdentifierValue extends MibValue {
@@ -199,6 +199,34 @@
     }
 
     /**
+     * Clears and prepares this value for garbage collection. This
+     * method will recursively clear any associated types or values,
+     * making sure that no data structures references this object.<p>
+     *
+     * <strong>NOTE:</strong> This is an internal method that should
+     * only be called by the MIB loader.
+     */
+    protected void clear() {
+        ObjectIdentifierValue  child;
+
+        super.clear();
+        if (getParent() != null) {
+            getParent().children.remove(this);
+        }
+        parent = null;
+        if (children != null) {
+            for (int i = 0; i < children.size(); i++) {
+                child = (ObjectIdentifierValue) children.get(i);
+                child.parent = null;
+                child.clear();
+            }
+            children.clear();
+        }
+        children = null;
+        symbol = null;
+    }
+
+    /**
      * Compares this object with the specified object for order. This
      * method will only compare the string representations with each
      * other.
@@ -281,9 +309,11 @@
     }
 
     /**
-     * Sets the symbol connected to this object identifier. This
-     * method is called during the value symbol initialization.
+     * Sets the symbol connected to this object identifier.<p>
      *
+     * <strong>NOTE:</strong> This is an internal method that should
+     * only be called by the MIB loader.
+     *
      * @param symbol         the value symbol
      */
     public void setSymbol(MibValueSymbol symbol) {
Index: src/java/net/percederberg/mibble/value/BitSetValue.java
===================================================================
--- src/java/net/percederberg/mibble/value/BitSetValue.java	(revision 190)
+++ src/java/net/percederberg/mibble/value/BitSetValue.java	(working copy)
@@ -16,7 +16,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  *
- * Copyright (c) 2004-2005 Per Cederberg. All rights reserved.
+ * Copyright (c) 2004-2006 Per Cederberg. All rights reserved.
  */
 
 package net.percederberg.mibble.value;
@@ -32,7 +32,7 @@
  * A bit set MIB value.
  *
  * @author   Per Cederberg, <per at percederberg dot net>
- * @version  2.6
+ * @version  2.7
  * @since    2.0
  */
 public class BitSetValue extends MibValue {
@@ -137,6 +137,20 @@
     }
 
     /**
+     * Clears and prepares this value for garbage collection. This
+     * method will recursively clear any associated types or values,
+     * making sure that no data structures references this object.<p>
+     *
+     * <strong>NOTE:</strong> This is an internal method that should
+     * only be called by the MIB loader.
+     */
+    protected void clear() {
+        super.clear();
+        value = null;
+        references = null;
+    }
+
+    /**
      * Returns all the bits in this bit set as individual number
      * values.
      *
Index: src/java/net/percederberg/mibble/MibSymbol.java
===================================================================
--- src/java/net/percederberg/mibble/MibSymbol.java	(revision 190)
+++ src/java/net/percederberg/mibble/MibSymbol.java	(working copy)
@@ -16,7 +16,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  *
- * Copyright (c) 2004-2005 Per Cederberg. All rights reserved.
+ * Copyright (c) 2004-2006 Per Cederberg. All rights reserved.
  */
 
 package net.percederberg.mibble;
@@ -27,7 +27,7 @@
  * unique within the MIB file. All symbols also have a data type.
  *
  * @author   Per Cederberg, <per at percederberg dot net>
- * @version  2.6
+ * @version  2.7
  * @since    2.0
  */
 public abstract class MibSymbol {
@@ -88,6 +88,14 @@
     public abstract void initialize(MibLoaderLog log) throws MibException;
 
     /**
+     * Clears and prepares this MIB symbol for garbage collection.
+     * This method will recursively clear any associated types or
+     * values, making sure that no data structures references this
+     * symbol.
+     */
+    abstract void clear();
+
+    /**
      * Returns the file location.
      *
      * @return the file location
Index: src/java/net/percederberg/mibble/MibLoader.java
===================================================================
--- src/java/net/percederberg/mibble/MibLoader.java	(revision 190)
+++ src/java/net/percederberg/mibble/MibLoader.java	(working copy)
@@ -16,7 +16,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  *
- * Copyright (c) 2004-2005 Per Cederberg. All rights reserved.
+ * Copyright (c) 2004-2006 Per Cederberg. All rights reserved.
  */
 
 package net.percederberg.mibble;
@@ -64,7 +64,7 @@
  * concurrently in multiple threads.
  *
  * @author   Per Cederberg, <per at percederberg dot net>
- * @version  2.6
+ * @version  2.7
  * @since    2.0
  */
 public class MibLoader {
@@ -506,7 +506,8 @@
                     throw new MibLoaderException(mib.getFile(), message);
                 }
             }
-            mibs.remove(pos);
+            mib = (Mib) mibs.remove(pos);
+            mib.clear();
         }
     }
 
