How to increase stack size of c++ in ubuntu?

Правка en2, от Slow_But_Determined, 2018-11-13 14:02:01

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.

Теги stack limit, c++, ubuntu

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский Slow_But_Determined 2018-11-13 14:02:01 145
en1 Английский Slow_But_Determined 2018-11-12 22:02:37 533 Initial revision (published)