I intend to allocate a large array of size 1073741824
(equivalent to 1GB e.g.) and then read from it randomly but i get segmentation fault (core dumped) for only defining the array as i checked which i do like:
unsigned int size = 1073741824;short arr = malloc(size * sizeof(short));
i also tried casting it as follows but still the same issue:
unsigned int size = 1073741824;short *arr = (short*) malloc(size * sizeof(short));
also the ulimit
command returns unlimited
so what am i doing wrong?