C++, a matrix of 100000 x 100000

Hello friends, I come to ask, why does my program stop execution with a “Killed” when I run it? this happens when I write 100000 onwards

Repl link:

//Random Generator of Matrix for the Q.A.P.


void printMatrix(const std::vector<std::vector<int>>& matrix);

int main(){
    int n;

    std::cout<<"Ingresa el numero de datos: ";

    std::vector<std::vector<int>> matrix1(n, std::vector<int>(n, 0));

    std::random_device rd;
    std::mt19937 gen(rd());
    std::uniform_int_distribution<> dis(1,100);

    for(int i=0;i<n;i++){
        for(int j= i + 1; j<n; j++){
            matrix1[i][j] = dis(gen);
            matrix1[j][i] = matrix1[i][j];



    return 0;

void printMatrix(const std::vector<std::vector<int>>& matrix) {
    for (const auto& row : matrix) {
        for (int element : row) {
            std::cout << element << " ";
        std::cout << '\n';

Hi @alexvaldiviacru , welcome to the forums!
This could be because your repl’s RAM may have exceeded its limits.


The site replit have a limit of RAM?

If they did not, then theoretically a single Repl could use all the RAM allocated to its server, which would negatively affect other Repls that also happened to be on that server.


Let’s say an int takes 4 bytes (that’s what I’m used to from C). Then your matrix would use up

4 x 100_000 x 100_000 / (1024 ** 3) ≈ 37 GiB

of RAM. A repl gives you 1 GiB (Starter) / 8 GiB (Core) RAM. So you’re a bit over the limit.