Given dimension sizes and bytes per element, checks that the total allocation size is safe. Catches negative/NA/Inf dimensions, integer overflow (by converting to double), and enforces the max allocation limit.
validate_allocation_size(
dims,
bytes_per_elem,
max_bytes = get_max_alloc_bytes()
)the total number of elements (as double), invisibly. The function stops with an error if the allocation would be unsafe.
numeric vector of dimension sizes (e.g., c(256, 256, 256)).
single numeric value, the number of bytes per element
(e.g., 4 for float32).
single numeric value, the maximum allowed allocation in bytes.
Defaults to the result of get_max_alloc_bytes(). Pass Inf to
disable the limit check (negative/NA/Inf dims are still rejected).