Skip to contentSkip to conversation

Performance of mmap/munmap on linuxppc 2.4

DISCUSSION Stephen Williams 1 participant 1 message Oct 1, 2004

lore
Share & tools
lore
#0 lore raw

I need to allocate, reallocate(down), and release lage image buffers, and I've been thinking in terms of using mmap and anonymous mapping to get the memory:

      void*ptr = mmap(0, cur->size_, PROT_READ|PROT_WRITE,
                      MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);

I also munmap the tail of this region when I know how big the image really is, and munmap the rest when the image is done. I'm doing this the hard way (instead of using malloc/realloc) because I want to guarantee that the realoc functionality doesn't move the data.

So am I shooting myself in the foot performance-wise here? I'm using a 233MHz 405GPr. I expect to be allocating/freeing these image buffers 30-50 times a second for 4meg-ish regions, or somewhat slower for regions 60meg or so. I have no swap.

Signature · 4 lines
Steve Williams                "The woods are lovely, dark and deep.
steve at icarus.com           But I have promises to keep,
http://www.icarus.com         and lines to code before I sleep,
http://www.picturel.com       And lines to code before I sleep."