commiting less than 64K for mmap'ed files on Solaris???

commiting less than 64K for mmap'ed files on Solaris???

Post by Chris Markl » Thu, 29 May 2003 13:52:26



Help SVP,

Seems like mmap() on Solaris uses a 64K segment (?) at minimum for
memory-mapped files... That is, even if I mmap() a 10-byte (e.g.) file, it
will allocate a minimum of 64K for that mapped file. Anyone know a way to
get mmap() on Solaris to commit less virtual storage to small mapped files?
(Yeah yeah I know that mapping small things can be done other ways, but I'd
like the specific question answered...)

Chris

 
 
 

commiting less than 64K for mmap'ed files on Solaris???

Post by Andrew Gabri » Fri, 30 May 2003 01:36:43




Quote:> Help SVP,

> Seems like mmap() on Solaris uses a 64K segment (?) at minimum for
> memory-mapped files... That is, even if I mmap() a 10-byte (e.g.) file, it
> will allocate a minimum of 64K for that mapped file. Anyone know a way to
> get mmap() on Solaris to commit less virtual storage to small mapped files?
> (Yeah yeah I know that mapping small things can be done other ways, but I'd
> like the specific question answered...)

It allocates guard zones between mapped areas by default. The size of
them depends on the allocation size and the sparc architecture. For
sun4u, I think it's 64k boundary for up to 500kb, and bigger guard
zones are used for larger allocations.

What I have done in the past is find and reserve a large area of virtual
address space using:

bigspace = mmap(0,size,PROT_NONE,MAP_PRIVATE|MAP_NORESERVE|MAP_ANONYMOUS,-1,0);

which is like one giant guard zone (or red zone, some call it).
Then mmap using explicit fixed addresses from within this area. You
get to choose if you want guard zones between your mapped areas, and
how big they are.

Some unixs won't let you re-mmap part of a mapped area (e.g. AIX when I
last tried), so this might not be portable, but it works fine on Solaris.

--
Andrew Gabriel
Consultant Software Engineer

 
 
 

1. commiting less than 64K for mmap'ed files on Solaris???

Help SVP,

Seems like mmap() on Solaris uses a 64K segment (?) at minimum for
memory-mapped files... That is, even if I mmap() a 10-byte (e.g.) file, it
will allocate a minimum of 64K for that mapped file. Anyone know a way to
get mmap() on Solaris to commit less virtual storage to small mapped files?
(Yeah yeah I know that mapping small things can be done other ways, but I'd
like the specific question answered...)

Chris

2. another irc-password-stealing attempt

3. Can mmap'ed files be extended ?

4. Help requested with arp/multicast

5. mmap()'ed files and holes...

6. lpd goes beserk

7. mmap'ed access to VMEmem space under Solaris 2.1

8. About reading lines from a file

9. F_SETLKW on a mmap'ed file fails

10. Can I share, via shmat(), an mmap()'ed file?

11. deleting mmap'ed files cause problems?

12. How to grow file which is mmap()'ed?

13. 2.4.18: writeback of shared mmap'ed files broken?