From: Elton Wildermuth
Subject: How do I determine space available?
Date: 
Message-ID: <8983@sybase.sybase.com>
In Common LISP, is there any function analogous to #'room that will return
values describing the remaining space in the environment?

I am working in Golden Common Lisp on a 386 clone; the project involves
loading very large networks from file.  These networks contain property
and constraint data as well as the nodes themselves.  For execution speed
and flexibility, I would like to store an in-memory stack of networks,
rather than having to reload from disk in order to switch contexts.

The problem becomes, how do I determine whether the next network will
fit in the memory remaining?  I can estimate the amount of cons and atom
space required to store a particular network, but short of resorting to
#'with-output-to-string and parsing the resultant text, I can't figure
out how to determine the machine's remaining capacity.

Thanks in advance for any help.

			-- Elton
+++
·····@fnord.sybase.com                        Elton Wildermuth
{pacbell,pyramid,sun,{uunet,ucbvax}!mtxinu}!sybase!fnord!elton
From: Barry Margolin
Subject: Re: How do I determine space available?
Date: 
Message-ID: <35359@think.Think.COM>
In article <····@sybase.sybase.com> ·····@fnord.sybase.com (Elton Wildermuth) writes:
>In Common LISP, is there any function analogous to #'room that will return
>values describing the remaining space in the environment?

No, there's no function that returns the amount of space left.  It's not
clear that this could be defined in a portable fashion.  In virtual memory
systems the total amount of space is virtually (sorry, couldn't resist)
unlimited, and certainly not fixed.  For instance, if a Unix Lisp
implementation were to report based on the amount of swap space available
it would be wrong, since swap space is shared by all the users of the
system.  And on a Symbolics system you can increase the amount of swap
space by using the "Add Paging File" command.

Another problem is how to define the units portably.  I suppose there could
be a size-of function that takes a type specifier (there would have to be
some restrictions on the type specifiers that could be used -- what would
(size-of '(satisfies user-defined-predicate)) return?), and the return
value could be in the same units as this returns.

And what about Lisp systems with multiple areas?  Should this function
include the space on areas that you're not likely to be allocating in?
Since areas aren't specified by Common Lisp it's not clear how a standard
specification of this function could deal with this.

To summarize, the notion of "space available" is extremely implementation
dependent, so you should talk to the vendors of the Lisp systems you use
and find out how to determine it for each system.  Provide a fall-back
implementation that assumes infinite space, for systems you haven't written
the implementation-specific code for.

--
Barry Margolin, Thinking Machines Corp.

······@think.com
{uunet,harvard}!think!barmar