#923·luxon

Constructing IANAZones has huge memory impact on nodejs

Author: sechelCreated Apr 20, 2021Updated Sep 21, 2026
Labelsissue: performance

I have not dug deep enough to really get to the bottom of the issue here but this should serve as a warning to all that use Luxon on nodejs along with timezones. I have an algorithm that uses timezones in its core loop. The first version reads like this:

typescript
const zone = new IANAZone(asset.timezone);
const assetHour = data.date.setZone(zone);
if (assetHour.hour !== 23) { return; }

which produced the following memory graph on the server (two instances running, scale is in MB) image So each run consumed roughly 1Gb of memory that could not be freed and eventually destabilized the whole stack. The new version that avoids using instances of IANAZone seems to avoid a crucial memory issue somewhere hidden in the IANAZone constructor or in the calls to setZone:

typescript
const assetHour = data.date.setZone(asset.timezone);
if (assetHour.hour !== 23) { return; }

This version does not consume any noteworthy memory anymore. After redeployment at 10:45 note the small bump at 10:55 that belongs to the invocation. image I find this stunning how two tiny seemingly equivalent pieces code can have such a huge difference in memory consumption.