C++

Notes

  • Allocate raw arrays on the stack vs. heap
    int n = 1 << 22; // 4MiB
    
    // Stack
    char x[n];
    
    // Heap
    char* x = new char[n];
    
    // Stack overflow
    // This fails because the default Linux stack size (ulimit -a) is 8MiB
    n = n << 1; // 8MiB
    char x[n];	
    

Resources

Edit