Re: strange stack limit behavior when allocating more than 2GB mem on 32bit machine
Glynn Clements <[email protected]>
| Newsgroups | org.kernel.vger.linux-c-programming |
|---|---|
| Message-ID | <[email protected]> |
Joe wrote: > Clear. But how comes 2000MB can be allocated when stack limit is unlimited? Because malloc() can allocate from the area reserved for the stack. The stack limit is a limit, not a reservation. If you set a small stack limit, there will be ~2.7 GiB below where the libraries are mapped and very little above it. If you set the stack limit to "unlimited", there will be ~850 MiB below where the libraries are mapped and ~2 GiB above it. malloc() can allocate from either of those areas, but any particular allocation must fit into one or the other. It can't split a single allocation between areas, and it can't move any existing mappings. -- Glynn Clements <[email protected]>