Changeset 12281


Ignore:
Timestamp:
11/22/09 19:11:54 (14 years ago)
Author:
ehuelsmann
Message:

Fix a memory leak for objects-with-documentation going out of scope,

by making the documentation hash table a WeakHashMap?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/LispObject.java

    r12279 r12281  
    3434package org.armedbear.lisp;
    3535
     36import java.util.WeakHashMap;
     37
    3638public class LispObject extends Lisp
    3739{
     
    588590  }
    589591
    590   private static final EqHashTable documentationHashTable =
    591     new EqHashTable(11, NIL, NIL);
     592  private static final WeakHashMap<LispObject, LispObject>
     593      documentationHashTable = new WeakHashMap<LispObject, LispObject>();
    592594
    593595  public LispObject getDocumentation(LispObject docType)
    594596
    595597  {
    596     LispObject alist = documentationHashTable.get(this);
     598    LispObject alist;
     599    synchronized (documentationHashTable) {
     600      alist = documentationHashTable.get(this);
     601    }
    597602    if (alist != null)
    598603      {
     
    607612
    608613  {
    609     LispObject alist = documentationHashTable.get(this);
    610     if (alist == null)
    611       alist = NIL;
    612     LispObject entry = assq(docType, alist);
    613     if (entry instanceof Cons)
    614       {
    615         ((Cons)entry).cdr = documentation;
    616       }
    617     else
    618       {
    619         alist = alist.push(new Cons(docType, documentation));
    620         documentationHashTable.put(this, alist);
    621       }
     614    synchronized (documentationHashTable) {
     615      LispObject alist = documentationHashTable.get(this);
     616      if (alist == null)
     617        alist = NIL;
     618      LispObject entry = assq(docType, alist);
     619      if (entry instanceof Cons)
     620        {
     621          ((Cons)entry).cdr = documentation;
     622        }
     623      else
     624        {
     625          alist = alist.push(new Cons(docType, documentation));
     626          documentationHashTable.put(this, alist);
     627        }
     628    }
    622629  }
    623630
Note: See TracChangeset for help on using the changeset viewer.