kevin lyda wrote:
> as i'm playing with linked list code today i was thinking this would be
> a nice addition to the malloc/free and friends api:
>> int malloc_reserve(int size, int how, int arg);
>> the idea is that you would specify how much memory you're going to
> allocate very soon, how it would be allocated (RESERVE_CALLS meaning
> number of calls to malloc, RESERVE_AVG meaning average size) and the
> arg for "how" (call count or average size respectively).
>> it would then return 0 if it can't, a reservation number >0 if it can.
>> when you hit the end of the code that malloc_reserve covered, you just
> call malloc_unreserve with the reservation number which would free up
> any extra memory it reserved.
>> the idea is that you can calculate an upper bound on the memory you're
> going to allocate and then reserve it. then you can call malloc and
> friends with no need to do out of memory checking.
Why? Just to make the code cleaner?
Your going to have to check the return from all calls
anyway because the kernel could overcommit mem?
Note this is controllable in Linux by putting 1 or 0 in:
Note also, ac kernels (rmap vm) support modes 2 and 3 in
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!