[metapost] ! MetaPost capacity exceeded

Taco Hoekwater taco at elvenkind.com
Sun Feb 8 11:47:55 CET 2009

Hi Steve,

Steve MC Han wrote:
> Hi Karl,
> Thank you for your response.
> It's just a simple recursion drawing.
> If you change froct(5) in picture 3, then the capacity is exceeded 
> 800000 already, which is strange because 8^5 is only 32768, even though 

The problem is not your basic programming logic, it just uses much
more memory than you think it does.

Each of the octagons has eight points, that are eight memory words a
piece, and the graphic object it is attached to is another nine words.
That makes each of the octagons worth a whopping seventy-three words.
(usage numbers are for mpost 1.110, yours could be a little different)

At the return from the iteration in froct(4), just the current picture
is therefore worth 341.640 memory words already. But so is the
picture variable h (still), there is some content left in h0, and the 
next thing you do it to copy currentpicture to h3. That means over 1M
is occupied just for the froct(4) iteration.

froct(5) will need 8 times that, so some 9MB in total would be
needed to complete that iteration.

> this looks more efficient to me, but in this case, it cannot even 
> perform 4 iterations. So, obviously, it is less efficient than the 
> original one.

Copying pictures means you need the memory twice. Metapost doesn't
know that you will clear one of them in the next iteration.

Best wishes,

More information about the metapost mailing list