1

I know that I can use these flags in .pro to increse the size of the stack and the heap in my c++ project in QT. But in linux it has no effect and I still have the stack size problem. How can I solve that in linux or is there an another solution?

QMAKE_CXXFLAGS += -Wl,--stack,100000000
QMAKE_CXXFLAGS += -Wl,--heap,100000000

2 Answers2

6

You are going about it all wrong. The stack is not about storing program data, it is about storing program state.

Large amounts of data should be on the heap, the stack is only what keeps the program code together, it is the backbone of the application, not its data base.

Try this instead:

QVector<YourType> data(100000000);

Provided the system can allocate enough memory, you now can use that data with the standard array [] operator.

Keep in mind that 100m ints are already over 380 mb. Even if you increase the stack size, nobody uses 380 mb stacks, the typical stack size is usually no more than a few megabytes, and that is good enough to work for immensely large applications. If your data type is larger, it will require even more continuous memory, so depending on your system and compiler, it is entirely possible that such an allocation cannot be made even on the heap.

dtech
  • 47,916
  • 17
  • 112
  • 190
0

You cannot change stack size by passing flags to gcc in Linux. You should use the command "ulimit -s newsize" to change it.

William
  • 761
  • 2
  • 10
  • 27