Nim Version
Pre-regression:
Nim Compiler Version 2.2.6 [Linux: amd64]
Compiled at 2026-03-01
Copyright (c) 2006-2025 by Andreas Rumpf
git hash: ab00c56904e3126ad826bb520d243513a139436a
active boot switches: -d:release
Post-regression:
Nim Compiler Version 2.2.8 [Linux: amd64]
Compiled at 2026-03-01
Copyright (c) 2006-2026 by Andreas Rumpf
git hash: 4f500679b196fad944caa50a753f5bbfaefda001
active boot switches: -d:release
Nim Compiler Version 2.3.1 [Linux: amd64]
Compiled at 2026-03-04
Copyright (c) 2006-2026 by Andreas Rumpf
git hash: 8e2547a5e2a616380b71cdcbc922770fa11aafb8
active boot switches: -d:release
Description
type U = object
d {.align: 32.}: int8
var e: seq[ref U]
for _ in 0 ..< 10000: e.add(new U)
echo getTotalMem()
Also notably, if one uses a variation of this:
type U = object
d {.align: 32.}: int8
var e: seq[ref U]
for _ in 0 ..< 10000: e.add(new U)
for f in e: echo cast[uint](addr f[]) mod 4096
in v2.2.8, every one byte (but sure, 32-byte-aligned) item is in its own 4096-byte, at a constant offset of 64 into said page, explaining the increased memory usage:
...
64
64
64
64
64
64
64
...
For v2.2.6, it shows:
80
128
176
224
272
320
368
416
464
512
560
608
656
704
752
800
and cycles around more gradually, with 48-byte strides.
Current Output
With v2.2.6: 1052672
With v2.2.8 and devel: 45916160
Expected Output
Known Workarounds
No response
Additional Information
No response