[GRASS-dev] Improving the G_calloc: unable to allocate xx bytes of memory message?
glynn at gclements.plus.com
Fri Oct 24 15:13:04 PDT 2014
Markus Neteler wrote:
> > r.basin map=map at Elevation prefix=o coordinates=-71.10394196,43.9865230801
> > threshold=19005 dir=C:\\Users\\Andrea\\Basins
> > I get:
> > " ....
> > v.to.rast complete.
> > All in RAM calculation...
> > Reading raster map <o_map_drainage_e>...
> > Calculating basins using vector point map...
> > Current region rows: 21612, cols: 21612
> > ERROR: G_calloc: unable to allocate 21612 * 4 bytes of memory at io.c:41
> Question: is there a way to also communicate in which *command* the
> memory allocation occurred, i.e. improve the error message?
Why should allocation errors be different to any other error?
For the case of scripts, it may suffice to fix run_command() etc so
that they terminate (or raise an exception) if the module returns a
non-zero exit status. If the error message is immedately followed by
"error executing <command>", it should remove most of the ambiguity.
> We have 9 files called "io.c" in GRASS 7.
> Ideal would be something like:
> ERROR: G_calloc: unable to allocate 21612 * 4 bytes of memory at r.thin/io.c:41
> ERROR: r.thin: G_calloc: unable to allocate 21612 * 4 bytes of memory
> at r.thin/io.c:41
> Not sure how to implement that in lib/gis/alloc.c
alloc.c is the wrong place. If you want errors to be traceable, the
module name should be included for *all* errors by G_fatal_error (and
Also, I wouldn't suggest using module/file.c, because that will be
inaccurate (and thus misleading) if the caller is part of a library.
If we just want the complete filename in allocation errors, we can
modify the compiler switches to include $(RELDIR) as per the attached
patch. Similarly for use of __FILE__ in the iostream headers.
Glynn Clements <glynn at gclements.plus.com>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the grass-dev