Re: Reg: Restarting the lisp listner through lisp code

David Tolpin <[email protected]> Wed, 15 Feb 2006 14:27:03 +0400
Newsgroups gmane.lisp.allegro
Message-ID <[email protected]>

> Hello All,
>
>        Iam very much new to lisp. I got struck up in the following   
> senario
>
> Iam loading large data into hash-tables and CLOS objects and  
> comparing the data. This needs to be done for N(say 100) number of  
> files. Iam getting system out of memory error when Iam contineously  
> loading files. But when Iam restarting the lisp listner for every  
> file this error is not comming. Iam restarting the lisp listner  
> because I dont need the data when the comparision is finished.

Hi Kumar,

Lisp has a garbage collector; but hash tables keep their entries  
forever, unless you help them get rid of them.

You have (at least) two options:

1) if you don't need data between files, you can simply call clrhash  
on all hash tables you are using between files.

2) if this is not easy to do, and data becomes obsolete at different  
points in time, you should consider using weak hash tables.

Weak tables is not a part of ANSI Common Lisp, but almost every  
implementation today has them as an extension, including Allegro  
Common Lisp. There is an excellent article by Brun Haible on weak  
references, http://www.haible.de/bruno/papers/cs/weak/ 
WeakDatastructures-writeup.html, although I don't think you must read  
to use weak tables.

The ACL's implementation of weak hash table is described in http:// 
www.franz.com/support/documentation/8.0/doc/implementation.htm#cl- 
make-hash-table-2

The implementation is, unfortunately, rather low-level and exposes  
details of underlying implementation instead of providing clean  
interface, but once you understand how it works, it is usable.

David