Avoiding mmap


Our application news/deletes objects that range widely in size. Perhaps due to this, we see that some of these calls are internally causing mmap() and munmap() to get invoked. mmap()/munmap() are taking 100s of microsecs and cumulatively, they are throwing off the real-time response of our application.

Are there techniques or other APIs to configure QNX from calling mmap/munmap? Assume we cannot get rid of the news/deletes nor afford to write to write our own memory manager.

Our application runs on QNX 6.2.1B


mmap/munmap are the only methods of increasing the heap size of the process, at run-time. Since you cannot get rid of the new/delete, and you cannot write you’re own memory manager, it will be very difficult to work around this system requirement. The only thing I can think of is to pre-allocate all of the memory that you will need, and only re-use the existing buffers. This will require that you change the new/delete. Aside from that one idea, I think it is impossible to do what you want, given the restrictions you’ve set.

Thanks for your reply.

You wrote “mmap/munmap are the only methods of increasing the heap size of the process, at run-time”… If this is possible, can I allocate a large enough heap during application startup? If so, how? Basically, I may be able to tradeoff memory with more consistency with our application runs? Any tips on good ways to estimate worst case heap would be helpful :slight_smile:

Reg your other suggestion: Are there any opensource/commercial packages available for QNX to do this type of memory management? QNX provided memory management seems ]quite limited in our case?

QNX memory manager is not deterministic and even doing a big malloc at startup isn’t guaranty to fix you problem (although from experience I can tell you it will). The only way to do this, is to mmap the ram yourself and then find a package on the web (there sure are plenty of them) that will allocated memory from the memory you mmaped. Problem is you must mmap enough memory when your application first start because if you need more memory you will have to call mmap ( there is no other way) which bring you back to your original problem.


If you know of particular memory managers and heap analyzers, please send pointers to them.

I’ve been searching the net and so far have come across many garbage collectors, memory leak detectors but few memory managers…none that seem to do exactly what I’m looking for. I must not be using the right search keywords. Anyway, I will keep trying…

Look for memory pool.