Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Apr 2003 12:32:45 -0800
From:      "Sreekanth" <>
To:        <>
Subject:   Mmap and malloc
Message-ID:  <000001c2fa20$2ee5ba20$ae28a8c0@SREELAPTOP>

Next in thread | Raw E-Mail | Index | Archive | Help
    I have a situation i am not sure i understand.I am running a 4.6.2
FreeBSD system with a Dual Xeon board with 2GB of Physical memory.I
have a test program which continuoulsy calls mmap(with larger size
each time) till it receives MAP_FAILED return value. I then call
malloc(with bigger memory size each time) continuosly till it
fails.Here are my results.

Max mem mapped = 714 MB
Max mem alloc = 308 MB

My MAXDMSIZ is 1200*1024*1024 and KVA_PAGE is 512 (2GB)

If i swap the order in wich mmap and malloc are called, then i get the
following result.
Max mem alloc = 1200MB
Max mem mapped = 711MB

My questions are as follows
1) Why is the difference between two approaches. ?
2) What exactly is the relationship between mmap malloc and KVA_PAGES.
3) I found that the Maximum mmapped memory = 4GB - KVA_PAGES*PAGE_SIZE
- MAXDSIZ - 134
What is the 134 value..? It is very consistent for me for various
values of KVA_PAGES and MAXDSIZ, so i am ruling it being just a

I hope somebody has already seen this kind of behaviour and therefore
can help me out..

Thanks in advance,

ps: If somebody needs the code i used to generate these results, i
would be more than happy to provide it.

Want to link to this message? Use this URL: <$2ee5ba20$ae28a8c0>