[CentOS] top and allocation issues

Thu Mar 3 23:31:40 UTC 2011
Ross Walker <rswwalker at gmail.com>

On Mar 3, 2011, at 2:21 PM, "Michael D. Berger" <m_d_berger_1900 at yahoo.com> wrote:

> In a context where exceptions are caught, I ran
> the fragment:
> 
>   cerr << "allocating" << endl;
>   char*    arr[100];
>   for (int jj = 0; jj < 10; ++jj)
>   {
>      cerr << "jj = " << jj << endl;
>      arr[jj] = new char[2000000000];
>      sleep (30);
>   }
>   sleep (10);
>   for (int jj = 0; jj < 10; ++jj)
>      delete[] arr[jj];
>   cerr << "deleted" << endl;
> 
> The exception was caught with jj = 1, i.e., on the second allocation.

In 32-bit a process can only allocate 3GB, 1GB is reserved for the kernel.

I don't know what your trying to do, but I'm sure your could do it a whole lot better the pre-allocating all available memory.

Don't go by top it only shows committed memory, not reserved.

-Ross