malloc garbage collection

Joel Sherrill joel.sherrill at OARcorp.com
Tue Feb 19 15:05:09 UTC 2008


Tim wrote:
> Hi Leon,
>
> Leon Pollak wrote:
>   
>> please, can somebody point me where can I find some words about memory garbage
>> collection in RTEMS - how is it done (if at all) and when?
>>
>>     
>
> To the best of my knowledge, there is no "garbage collection system" in
> rtems, not like java/mono et al. AFAIK, heap memory management is taken
> care of by the programmer using malloc/free and new/delete.
>
> The only thing close to garbage collection that I'm aware of is calling
> free() in an ISR - these free's are not processed immediately. Instead
> they are added to a list (chain), which is processed the next time
> malloc() is called.
>
> Have a look in cpukit/libcsupport/src/malloc.c (I'm using rtems-4-8-branch)
>
>   
This is an accurate description.  The "deferral" list in free()
is necessary because you can't perform heap operations in
an ISR.  But since device drivers may free buffers in an ISR,
in seemed like a reasonable thing to do so users wouldn't
have to create their own mechanisms to accomplish the
same thing.

When you free a block of memory, all coalescing takes place
as part of the free.  So there is truly no garbage to collect.
If there is garbage, it is because the application didn't take
care of its own trash. :-D

--joel
> Tim
>
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.com
> http://rtems.rtems.org/mailman/listinfo/rtems-users
>   


-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill at OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
   Support Available             (256) 722-9985





More information about the users mailing list