Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: thread safeness II



Rainer Zocholl <UseNet-Posting-Nospam-74308-@zocki.toppoint.de> wrote:

[..]

> The "costly" malloc may be avoided by using a "queue" which 
> contains preallocated memory blocks.
> Instead of freeing the memory, the calling task simply 
> returns the pointer back to the queue.
> The disadadvantage: you must know how many memory blocks in 
> what size you need.
> The advantage: This works with a not-thread-safe-malloc too
> and is really fast.
> But is a malloc really so costly or the function called that often?

malloc() is pretty cheap. it is usually implemented as you suggested
above. libc reserves some memory for later mallocs and just calls brk()
seldomly. i would not worry about it. 

clemens




Home | Main Index | Thread Index