[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: make-vector/vector-length disagree for large vectors.
From: |
Martin Grabmueller |
Subject: |
Re: make-vector/vector-length disagree for large vectors. |
Date: |
Wed, 07 Feb 2001 22:58:55 +0100 |
> From: Rob Browning <address@hidden>
> Date: 07 Feb 2001 14:06:59 -0600
>
> guile> (define xxx (make-vector 1000000))
> guile> (vector-length xxx)
> 1000000
> guile> (define xxx (make-vector 100000000))
> guile> (vector-length xxx)
> 16113920
> guile> (version)
> "1.4"
I am not able to reproduce this. Both 1.3.4 and 1.4.1 give:
guile> (define xxx (make-vector 100000000))
standard input:1:13: In procedure make-vector in expression (make-vector
100000000):
standard input:1:13: Memory allocation error
ABORT: (memory-allocation-error)
A vector of this size requires 381.47 MB of memory, and my box has
only 256 Megs (128 RAM + 128 Swap).
So I can only guess: If I have understood the data representation
correctly, vectors (and strings) can have at most 16777216 elements,
because only 24 bits are reserved in the vector's cell for storing the
length.
(expt 2 24) => 16777216
I don't think that this limit could be changed without breaking all of
the vector code, but at least `make-vector' should throw an error if
the requested size is too large.
A patch for this particular problem is attached below, but I don't
know where to put constants like SCM_MAX_VECTOR_LENGTH and there are
probably more places in the code where this fix is necessary (for
example, try `(make-string 100000000)'). And, of course, all these
limitations should be documented.
Regards,
'martin
--
Martin Grabmueller address@hidden
http://www.pintus.de/mgrabmue/ address@hidden on EFnet
===File ~/cvs/guile-core/libguile/diff-vec==================
Index: vectors.c
===================================================================
RCS file: /cvs/guile/guile-core/libguile/vectors.c,v
retrieving revision 1.42
diff -c -r1.42 vectors.c
*** vectors.c 2001/02/02 04:56:25 1.42
--- vectors.c 2001/02/07 21:59:53
***************
*** 277,288 ****
--- 277,293 ----
}
#undef FUNC_NAME
+ /* This is 2**24 */
+ #define SCM_MAX_VECTOR_LENGTH 16777216
+
SCM
scm_c_make_vector (unsigned long int k, SCM fill)
#define FUNC_NAME s_scm_make_vector
{
SCM v;
scm_bits_t *velts;
+
+ SCM_ASSERT_RANGE (1, SCM_MAKINUM (k), k <= SCM_MAX_VECTOR_LENGTH);
SCM_NEWCELL (v);
============================================================