2 ms·
> In all of recorded history, has a malloc() call for more than 2GB ever actually succeeded anywhere? Yes, on OS X 10.5, and on 32-bit Linux with Glibc until t
by pascal_cuoq 7y ago
> In all of recorded history, has a malloc() call for more than 2GB ever actually succeeded anywhere?
Yes, on OS X 10.5, and on 32-bit Linux with Glibc until two days ago.
The article I linked, written before Glibc 2.30 was released, is from a period when every Unix had been allowing “malloc(0x80000001);” in 32-bit processes until recently; only OS X had had the courage to make that allocation fail. Sorry if the article doesn't make it clear enough that this is the context it is written in, but in its defense, you only needed to try it (and still need today to try it if you didn't upgrade Glibc) to see that it succeeds. Or do you think that the Glibc developers wrote a Changelog entry to explain that they changed something that didn't actually change?
Linux's default limit on 32-bit has been 3GiB for a while, i think: https://stackoverflow.com/a/5080778/139746 https://stackoverflow.com/a/5080778/139746
Windows's limit is 2GiB by default, but this is only a default and 32-bit processes can be allowed access to more memory, up to IIRC nearly all of the theoretical maximum 4GiB for 32-bit processes running on 64-bit Windows.
- ajross 7y agoThe (sarcastic) point was about the fact that no real world code actually relied on a malloc() of half the address space. I'm sure it "worked" in some sense, though I'd be really surprised if you could make that happen with a default-linked C program on any distro that ever shipped. The holes just aren't big enough. You'd need to link the app with special care, and potentially write your own dynamic loader to keep the region you wanted free. And if you do that... you might as well just mmap() the thing. The point was that doing this with the system heap on a 32 bit system was never a serious thing. There are apps that would do management of memory spaces that large, but they didn't do it with malloc.