|
From: | Wolfgang Laun |
Subject: | Re: [bug-gawk] Memory usage of multi-dimensional arrays |
Date: | Fri, 16 Mar 2018 08:27:32 +0100 |
Hi all,
I encountered an interesting behaviour with multi-dimensional arrays and
was wondering, if this is expected or a bug:
Example 1:
## create array with 100k elements
BEGIN { for (I = 0; I < 100000; I++) X[I] = 0 }
## wait to allow for memory analysis
END { while (1 == 1) Y = 0 }
Result:
The memory usage (looked at with "ps" and all its limitations) is of
order a few (~8) bytes per element, as expected.
Example 2:
## create multi-dimensional array with 100k elements
BEGIN { for (I = 0; I < 100000; I++) X[I][I] = 0 }
## wait to allow for memory analysis
END { while (1 == 1) Y = 0 }
Result:
Uses a few (~4) kB per element. This also means, an array with 1m
elements cannot even be created on a machine with 8 GB RAM anymore.
I could not find any documentation on that behaviour. If it is
considered "normal", could you mention this somewhere, please? Is there
a way to make these arrays more efficient?
Thank you very much for any comments.
Best regards,
Christian
P.S.: Please CC me, as I am not subscribed.
P.P.S.: version:
GNU Awk 4.1.4, API: 1.1 (GNU MPFR 3.1.5, GNU MP 6.1.2)
from: Debian 9.4, amd64
[Prev in Thread] | Current Thread | [Next in Thread] |