[GRASS-dev] graph function input limitations

Paulo van Breugel p.vanbreugel at gmail.com
Thu Nov 22 00:45:11 PST 2012


On 11/22/2012 05:38 AM, Glynn Clements wrote:
> Paulo van Breugel wrote:
>
>>> The limit would depend upon the number of columns in the current
>>> region and the amount of memory available.
>> OK, but what I find strange is that using 2400 terms uses less then 2.5
>> GB, I would not expect 2500 terms to use more then 12 GB (amount of RAM
>> available) in that case.
>> I also tried to run a r.mapcalc with 2600 terms for a map of 15 x 19
>> cells. Also here I got the message: "memory exhausted", which can
>> hardly be related to lack of memory?
> Right. Debugging indicates that the error actually comes from the
> parser, which by default limits the stack to 10000 items. This can be
> overridden by defining the macro YYMAXDEPTH in mapcalc.y.
>
> Given that it fails at just under 5000 arguments (each x,y pair adds 2
> arguments), I'm assuming that each extra argument to graph() requires
> 2 stack levels, so the value should be just over twice the maximum
> number of arguments.
>
> With the following change, it has no problems with 5000 arguments:
>
> 	--- raster/r.mapcalc/mapcalc.y	(revision 53964)
> 	+++ raster/r.mapcalc/mapcalc.y	(working copy)
> 	@@ -12,6 +12,7 @@
> 	
> 	 #define YYDEBUG 1
> 	 #define YYERROR_VERBOSE 1
> 	+#define YYMAXDEPTH 100000
> 	
> 	 static int syntax_error_occurred;
>
> To be honest, I'm not sure that it's worth increasing this value in
> the standard version. 5000 arguments in a function call is rather
> extreme, and probably a hint that alternative approaches should be
> considered.
>
What are the possible disadvantages of increasing this limit? But you 
are right, there aren't probably many user cases where more then 5000 
arguments are used. And as my case illustrates, there might be better 
alternatives. In any case, would it be possible to change the error 
message when the limit is surpassed from the generic 'memory exhausted', 
to something along the lines of "maximum number of function arguments 
exceeded"? And possibly, this limitation could be mentioned in the help 
file?

Thanks

Paulo

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20121122/d9247067/attachment-0001.html>


More information about the grass-dev mailing list