Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

augment stack dimension on shiny server

Tags:

stack

r

shiny

I'm working on a shiny server and I'm doing some quite complex operations. The problem I've found is that, after some minutes working on large data frames, the app crashed with this error: Error: C stack usage 7969194 is too close to the limit. Execution halted. I googled it and I've found that from the cmd in ubuntu with this command ulimit -s 16384 you can augment the stack size but I didn't find how to do it in the shiny server.

Please, does someone have some ideas?

Thank you

like image 270
Luca Triboli Avatar asked May 20 '26 09:05

Luca Triboli


1 Answers

TLDR:

Add the following lines to the end of /etc/security/limits.conf:

* soft memlock unlimited
* hard memlock unlimited

* soft stack unlimited
* hard stack unlimited

Credited to this answer. Bascially this change will adjust the size of stack and memlock memories to unlimited.

More Background:

As OP points out, one can use ulimit to adjust available stack size before entering an R session.

The R package rlimit is supposed to work just like the command line utility ulimit, however, I cannot produce the same behavior after entering into an R session:

Cstack_info()["size"] # prints 7969177
rlimit_stack(16384, 16384) # expect 16777216
Cstack_info()["size"] # still prints 7969177

Eventually I found the above TLDR solution and Error: C stack usage 7969194 is too close to the limit. Execution halted. goes away.

like image 132
Huang C. Avatar answered May 22 '26 01:05

Huang C.