I've encountered this while working with the Netflix data:

  $var=: ?1e9$~_10+2^20      NB. 10 less than 2^20
1048566
  4*$var                     NB. Data should take this much space
4194264
  7!:5<'var'
4194304                    NB. OK

  $var=: ?1e9$~_9+2^20      NB. but one element longer: 9 less than 2^20
1048567
  4*$var                     NB. Data should take this much space
4194268
  7!:5<'var'                NB. However, this pushes past some allocation
8388608                      NB.  boundary->allocate new block?

It looks like J uses a scheme whereby it allocates a new memory block that
effectively
doubles the memory allocated when the memory required is greater than
something near
a power of two.  The slight difference is probably header-related.

It may be using some kind of "buddy" system (see
http://en.wikipedia.org/wiki/Buddy_memory_allocation)
or perhaps it's relying on the OS which is using such an algorithm.

On 1/5/07, Michael Berry <[EMAIL PROTECTED]> wrote:

The quick and helpful answers I get from this list encourage me to ask
more
questions. I hope that is OK.

In my mental model of how things work, I imagine a J array to be stored as
a
fixed size header (or a header of size that is a function of the array
rank)
followed by the array contents. According to 7!:5, my floating point array
seems to take up more space that that. This in on 32-bit Windows.


   $rater_sig02
480189 19
   8**/$rater_sig02
72988728
   7!:5 <'rater_sig02'
134217728
   (7!:5 <'rater_sig02')%*/$rater_sig02
14.7111


In addition to just intellectual curiosity, my practical question is
whether
I need to think about anything beyond the number of elements and the type
of
my array when creating a mapped file to contain it.

-Michael

===============
Michael J. A. Berry
Data Miners, Inc.
+1 617 742 4252


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm




--
Devon McCormick
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to