# [metapost] ! MetaPost capacity exceeded

Steve MC Han hmc0907 at yahoo.com
Sun Feb 8 17:29:27 CET 2009

```Sorry again I forgot to include metapost at tug.org

Hi Taco,

Thank you very much for your explanation, even though I don't understand 100%.

Here are some of my naive questions for you.

1. Since many PC has more than 1G memory, why can metapost use them all? Is there any specific reason to restrict 800,000 for metapost?

2. Is there anyway just store one picture, and rotate the same picture in different location instead of storing all the pictures in every different location? In this case, store one picture and location storage would be needed. Or is this too dumb question?

Thank you again for your detailed description. I'll have to study more about PC memory, stuff

Steve

--- On Sun, 2/8/09, Taco Hoekwater <taco at elvenkind.com> wrote:

From: Taco Hoekwater <taco at elvenkind.com>
Subject: Re: [metapost] ! MetaPost capacity exceeded
To: hmc0907 at yahoo.com
Cc: "Karl Berry" <karl at freefriends.org>, metapost at tug.org
Date: Sunday, February 8, 2009, 2:47 AM

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,
Taco

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tug.org/pipermail/metapost/attachments/20090208/4beef3b2/attachment.html
```