-
Notifications
You must be signed in to change notification settings - Fork 103
Description
I am processing image files into h3 cells which convert a bounding box for each pixel in the Geo TIFF file into h3 cells at the specified resolution (in this case res 10). The code works perfectly for a while, but after a certain amount of processing memory errors occur.
For example, with these bounds:
E -69.36043436899354, W -69.36251770199354, N 81.41166741399798, S 81.40958408099797
this error is eventually thrown AFTER a large number of bounding boxes, at the same size / resolution, have been successfully processed:
Error: Memory allocation failed (code: 13)
at createError (.../node_modules/h3-js/dist/h3-js.js:13664:13)
at H3LibraryError (.../node_modules/h3-js/dist/h3-js.js:13683:10)
at throwIfError (.../node_modules/h3-js/dist/h3-js.js:13709:11)
at Object.polygonToCells (.../node_modules/h3-js/dist/h3-js.js:14757:7)
at ...
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 13
code 13
(more errors)
OOM
OOM
abort(OOM). Build with -s ASSERTIONS=1 for more info.
Similarly:
E -69.35835103599354, W -69.36043436899354, N 81.41166741399798, S 81.40958408099797
Error: Array length out of bounds (code: 1001, value: 16544021374)
at createError (.../node_modules/h3-js/dist/h3-js.js:13664:13)
at JSBindingError (.../node_modules/h3-js/dist/h3-js.js:13698:10)
at validateArrayLength (.../node_modules/h3-js/dist/h3-js.js:13866:11)
at Object.polygonToCells (.../node_modules/h3-js/dist/h3-js.js:14752:17)
at ...
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 1001
}
Here's an extract from the code that fails:
let bounds = [[
[ west, south ],
[ east, south ],
[ east, north ],
[ west, north ],
[ west, south ]
]];
hextilles = h3.polygonToCells(bounds, 10, true);
The code starts to fail after around c. 10-20 millions calls to polygonToCells. Note the same issue happens with both versions 3 and 4 of the library.
Encountering the issue with Node v 17.8.0, on both Intel and Apple Silicon Macs.