Блог пользователя Slow_But_Determined

Автор Slow_But_Determined, история, 8 лет назад, По-английски

I usually write:

'#define N 1000000

vector adj[N];

But when I run it locally, I get segmentation fault due to stack size being too small, so I end up reducing N to something like 10000 and forget to change it back again before submitting, causing unnecessary penalties.

So is there anyway to permanently increase stack size in ubuntu?

g++ -Wl,--stack=268435456 file.cpp works in Windows.

ulimit -s unlimited only increases stack size for the specific terminal

UPD:

Thanks a lot for your replies, I ended up spilling water on my laptop :(

I'll try the suggestions when (if?) My laptop gets dried.

  • Проголосовать: нравится
  • +24
  • Проголосовать: не нравится

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +15 Проголосовать: не нравится

Add ulimit -s unlimited to .bashrc?

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

you can do that from code (with smth like this)

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Why not modify the /etc/security/limits.conf file? A line like

your-username     soft    stack    1048576

should set your (soft) stack limit for all your processes to 1 GB by default. (The change might require a log-out/log-in in order to take effect.) For more info, please refer to man limits.conf.

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by Slow_But_Determined (previous revision, new revision, compare).