[GRASS-dev] Improving the G_calloc: unable to allocate xx bytes of memory message?

Glynn Clements glynn at gclements.plus.com
Mon Oct 27 08:33:24 PDT 2014

Markus Neteler wrote:

> Ok, I tried that patch but I don't manage to trigger it.
> GRASS 7.1.svn (nc_spm_08_grass7):~ > g.region rast=elevation -p res=0.01

> rows:       1350000
> cols:       1500000
> cells:      2025000000000

That's 1.8 * 2^40 cells; at 24 bytes/cell, it would be 44 TiB.

> GRASS 7.1.svn (nc_spm_08_grass7):~ > r.cost roadsmajor output=bla
> start_coordinates=637500.000000,221750.000000
> WARNING: segment zero_fill(): Unable to write (No such file or directory)

So it's not trying to allocate 44 TiB of RAM, it's trying to create a
44 TiB segment file, which fails for other reasons.

You'll need to find something which actually allocates RAM rather than
a temporary file. Try "r.proj memory=..."; this allocates the cache
memory before creating any temporary file.

> WARNING: Could not write segment file
> ERROR: Can not create temporary file
> Yet a bit unhelpful :-) It comes from lib/segment/format.c but I
> didn't manage to improve that.


	if (write(fd, buf, n) != n) {
	    G_warning("segment zero_fill(): Unable to write (%s)", strerror(errno));

ENOENT ("No such file or directory") isn't a valid error code for
write(). But errno is only set if write() returns -1, so it's likely
that write() returned a short count rather than failing and the errno
value is left over from a previous system call (sucessful calls don't
reset errno to zero). In all probability, the next call to write()
would have failed due to ENOSPC, EDQUOT, or EFBIG (or raised SIGXFSZ
if RLIMIT_FSIZE is being exceeded).

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-dev mailing list