1. Out of Memory

Hi

I've made a sequence like this:

atom ph,pw
ph=1250
pw=1750

global sequence ps
ps=repeat(repeat(250,ph),pw)

No problem.

But when I run the following procedure, eventually the program crashes with
an "out of memory" error.

If I make ph and pw larger, then the program still initializes, but it
crashes sooner in the procedure.

global procedure Directfield(sequence poles)
sequence Field, row, loca
loca={{},{}}
    for j=1 to ph do
        for i=1 to pw do
        outahere()
         loca[x]=i
         loca[y]=j
         Field=Measure_field_at(loca, poles)
         ps[i][j]=strange(Degree(Aangle(Field[x], Field[y])), numcolours,
360) -- evaluates to an atom
        end for
    end for
end procedure

Kat mentioned a while ago that each sequence element takes 4 bytes. My 1250
x 1750 sequence would only have about 8,750,000 bytes by that measure. My
system has 64mb ram. So why the memory error?
Thanks
Bye
Martin Hunt

simulat at intergate.bc.ca

new topic     » topic index » view message » categorize

2. Re: Out of Memory

Martin,

You need 16 bytes per atom, plus 24 bytes overhead for each sequence:

    (16+16+24) * 1250 * 1750 + 24 = 122,500,24 bytes

jiri

new topic     » goto parent     » topic index » view message » categorize

3. Re: Out of Memory

Correction, Martin! I wrongly assumed you had a *pair* of coordinates
in each case, stupid. In your case you actually need only

    ((16 * 1250) + 24) * 1750 = 35,042,000 bytes

But the system probably needs to hold *two* copies of the sequence at
some stage, not to mention operating system requirements. I hope I am
right this time :)  jiri

new topic     » goto parent     » topic index » view message » categorize

4. Re: Out of Memory

Thanks Jiri

Yeow - 16 bytes per atom is a lot of overhead! Maybe I'll need to try some
kind of direct memory access instead of using sequences for this. Darn.

But why will the sequence initialize without problems, but then crash later
as it's being used? As far as I can tell the sequence size should be staying
the same with the contents only being modified.

Bye
Martin

----- Original Message -----
From: Jiri Babor <J.Babor at GNS.CRI.NZ>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Sunday, April 09, 2000 4:01 PM
Subject: Re: Out of Memory


> Correction, Martin! I wrongly assumed you had a *pair* of coordinates
> in each case, stupid. In your case you actually need only
>
>     ((16 * 1250) + 24) * 1750 = 35,042,000 bytes
>
> But the system probably needs to hold *two* copies of the sequence at
> some stage, not to mention operating system requirements. I hope I am
> right this time :)  jiri
>

new topic     » goto parent     » topic index » view message » categorize

5. Re: Out of Memory

On Sun, 9 Apr 2000 16:12:58 -0700, simulat <simulat at INTERGATE.BC.CA> wrote:

>Thanks Jiri
>
>Yeow - 16 bytes per atom is a lot of overhead! Maybe I'll need to try some
>kind of direct memory access instead of using sequences for this. Darn.

Be prepared to lose a lot of speed peek-poking atom_to_float64s

>But why will the sequence initialize without problems, but then crash later
>as it's being used? As far as I can tell the sequence size should be
staying
>the same with the contents only being modified.

You initialized the sequence to integers which take only 4 bytes apiece plus
sequence overhead:

ps=repeat(repeat(250,1250),1750)

sizeof ps ~= 24 + 1750*(24 + 4*1250) = 8,792,024 bytes

but when you start assigning non-integer values to the sequence, each
integer mutates into a 16-byte atom thus slowing increasing to about:

24 + 1750*(24 + 16*1250) = 35,042,024 bytes like Jiri said


A solution might be to store the return values as fixed-point integers:

        ps[i][j]= floor(
  strange(Degree(Aangle(Field[x], Field[y])), numcolours,
  360) -- evaluates to an atom
      * #10000) -- evaluates back to integer

Then whenever you want to get an element out of ps, you have to remember to
divide by #10000 to get its actual value.  This would have to same memory
requirements as the integer size.

--
Pete Eberlein

>Bye
>Martin
>
>----- Original Message -----
>From: Jiri Babor <J.Babor at GNS.CRI.NZ>
>To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
>Sent: Sunday, April 09, 2000 4:01 PM
>Subject: Re: Out of Memory
>
>
>> Correction, Martin! I wrongly assumed you had a *pair* of coordinates
>> in each case, stupid. In your case you actually need only
>>
>>     ((16 * 1250) + 24) * 1750 = 35,042,000 bytes
>>
>> But the system probably needs to hold *two* copies of the sequence at
>> some stage, not to mention operating system requirements. I hope I am
>> right this time :)  jiri
>>

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu