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

Revision en1, by Slow_But_Determined, 2018-11-12 22:02:37

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

Tags stack limit, c++, ubuntu

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Slow_But_Determined 2018-11-13 14:02:01 145
en1 English Slow_But_Determined 2018-11-12 22:02:37 533 Initial revision (published)