1834543 Members
3662 Online
110069 Solutions
New Discussion

mmap limitation

 
K.C. Chan
Trusted Contributor

mmap limitation

Does any know if there is a limitation on how much mmap can allocate? What is the max memory can mmap allocate? FYI, I am running with 4Gbytes and 1Gbytes of swap. The flavor is RedHat 7.3 running kernel 2.4.18. Thanks.
Reputation of a thousand years can be determined by the conduct of an hour
4 REPLIES 4
Stuart Browne
Honored Contributor

Re: mmap limitation

According to documentation and kernel-source:

man mmap:
void * mmap(void *start, size_t length, int prot , int flags, int fd, off_t offset);

linux/types.h
typedef __kernel_size_t size_t;

asm/posix_types.h
typedef unsigned int __kernel_size_t;

So.. How long is an unsigned int these days?

With a bit of creativity, limits.h reports:

/* Maximum value an `unsigned int' can hold. (Minimum is 0.) */
# define UINT_MAX 4294967295U

Now, as to whether there is any other sort of limitation in place, I'm unsure. You'd have to poke through the kernel documentation. I recall limitations on memory page sizes for non-enterprise kernel builds.
One long-haired git at your service...
K.C. Chan
Trusted Contributor

Re: mmap limitation

Is there a way (like kerneal tunable parameter) to tell the system that I can use more than 2 gbytes when using mmap, since my physical memory is 4gbytes and swap is 1Gbytes. Thanks.
Reputation of a thousand years can be determined by the conduct of an hour
Stuart Browne
Honored Contributor

Re: mmap limitation

Can't help there. If you can't get your answer from the Kernel source directly, you might want to ask in a kernel developers list (see http://www.kernel.org/ under 'Mailing Lists'), or spend some time with google.
One long-haired git at your service...
K.C. Chan
Trusted Contributor

Re: mmap limitation

All,
I have not gotten back into investigating max limitation on kernel2.4 regarding how much sharemem can mmap allocate? But now I am looking into something similar and I am wondering if some one could shed some lights onto this. Here's what bother me, when I check the sharemem list via ipcs I do not see the expected sharemem on the list. But according to top, my application has allocated 400Mbytes of share memory (which is allocated via mmap). could any one explain why top see the sharemem where as ipcs does not see the sharemem which our application has allocated.
Reputation of a thousand years can be determined by the conduct of an hour