Page 1 of 1

Memory Management

Posted: Thu Feb 02, 2012 3:19 am
by rallysjd
Hi Giovanni,
The more I work with chibiOS the more I appreciate the code and doc consistency, and of course the responsive support. 2.3.4 now runs correctly on top of a core DFU section so we can update chibiOS directly over USB.

My next issue is understanding memory management: I see the docs on Heaps, Memory Pools, Dynamic Threads and Memory Streams. We are porting a subset of our scripting language (PiXCL) that (in Windows) create a series of linked lists, and also needs to store lists of icons and bitmaps.

Q1. Do the memory management (excluding Memory Stream) functions work on RAM only, or Flash as well?

Q2: There is no chHeap compacter function. I can see a situation where RAM gets quite fragmented, and compaction would be of benefit. Do you see this as not being necessary, adding complexity or something else?

Q3: The PiXCL interpreter linked list objects are the same size for each list. Do you recommend creating a set of Memory Pools for this?

Q4. The Memory Streams msObjectInit function can create RAM or ROM objects. Does ROM equate to Flash?

Q5: Our DFU, chibiOS, and PiXCL will all be in Flash. Some of the PiXCL lists are static once created, and could be resident in Flash with no problem. If I write some Flash memory management code, would this be considered modifying the kernel (hence disclosable) or my work, hence non-disclosable?

Re: Memory Management

Posted: Thu Feb 02, 2012 8:47 am
by Giovanni
Hi,

About your questions:

Q1) RAM only. In the development forum there are ongoing discussions about implementing a Flash Storage subsystem.

Q2) Not possible because the heap allocator returns pointers to allocated block, a compactor would have to modify all pointers to the allocated blocks and this is not possible, also, allocated blocks may contain data that is not relocatable. A different allocator scheme would be needed, implementing abstract references rather than pointers.

Q3) Memory Pools are always recommended when you have to handle lots of objects with the same size. Dynamic list are a typical application.

Q4) The MemoryStream object is just a file residing in memory, it is used when you want to access memory data using the streams interface. In this case ROM equates to Flash. Read only data.

Q5) It is your code, the only limit you have is that you can't modify the ChibiOS/RT stable code in commercial applications.

Giovanni