How to allocate more memory for your program (GCC)

I want to allocate more memory for the program. What is the gcc flag that allows this to be done?

FYI, what I'm trying to do is create a very large matrix (very large), which will later go through compression algorithms. Therefore, I cannot avoid creating such a large matrix for storing data.

+3
source share
4 answers

Your question is very unclear, but I suspect that you are trying to create a large multidimensional array (matrix) as a local variable (auto variable) for some function (possibly the main one), and this does not work.

int foo(int boo, int doo) {
    int big_array[REALLY_BIG];
    ...

, C , . , , ( , ), , , , , .

, , - -.

static , . , ( ), , , , , .

malloc calloc .

- ( * nix) - , . mmap .

mmap static , (, mmap, ) , . , .

+3

, , . 32- Windows , , 980 . Linux 1,5 .

64- .

, . . , , , SSE ..

, Intel AMD.

+3

gcc-.

malloc .

If you are somehow forced to use a static array or if your environment is configured by default to restrict your program’s access to virtual memory, you may need a command ulimit.

ulimit -v unlimited
ulimit -d unlimited

Otherwise, you need to more clearly indicate the error you are getting, which prevents you from getting enough memory and probably also tell us how big your matrix is.

+3
source

Use a bunch! malloc()and friends are your friends.

+2
source

Source: https://habr.com/ru/post/1764898/


All Articles