I am having a big issue of this G_malloc Error while using a module of Grass (6.4.4) (r.stream.extract) in R. Initially I thought my computers configuration was low, So I switched to 8gb Ram 64-bit Windows 10. And I found error occurring again. I tried setting the g.region to the current using DEM with the following function.

"execGRASS("g.region",flags= "a", parameters=list(rast="DEM")"

The error function is:

"execGRASS("r.stream.extract", flags="overwrite", parameters=list(elevation="DEM", accumulation="Accumulation", threshold=round(AT_mean[[i]], digit=0), mexp=0.01, stream_rast="Stream_Comparison"))"

and the error is as follows:

"Current region rows: 8129, cols: 10704 ERROR: G_malloc: unable to allocate 696102528 bytes of memory at main.c:259 Warning message: running command 'r.stream.extract.exe --overwrite elevation=DEM accumulation=Accumulation threshold=6 mexp=0.01 stream_rast=Stream_Comparison' had status 1"

I tried solving it in many ways such as, allocating memory using memory.limit(), setting up the computational region and also dividing the DEM into half. But nothing was successful.

  • Are your tools also 64bit (R, grass, any other plugins, etc...)? Any 32 bit process will be limited to 2GB of RAM regardless of how much RAM the machine has, even if the operating system is 64bit. – Evil Genius Nov 18 '15 at 12:40
  • Your threshold value looks VERY low to me. with 8000X10000 pixels, you have over 80 million cells. With a threshold of 6 you will be trying to create more than 10 million tiny drainage areas and stream reaches. – Micha Nov 18 '15 at 21:48
  • @EvilGenius Thanks for the clarification. I spotted out that I am using 32 bit grass and unfortunately the version I required doesnt have a stable 64-bit version. – flyingclouds Nov 21 '15 at 15:42
  • @Micha Yeah, I also found out that my DEM is wrongly projected and it is causing some inane accumulation values and threshold as well. Thank you for giving your insights on it. – flyingclouds Nov 21 '15 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.