Gerhard Fiedler wrote: > This is exactly what I'm talking about. You need to "design" the memory > usage; you can't just use willy-nilly malloc/free the way you'd do it in > a typical desktop or server application. > > So, even if you use malloc/free, you need to design how much of your > memory is needed, worst-case, for every part where you use dynamic > memory, you need to design how much of it is needed in total, > worst-case, by all parts that use dynamic memory together, and you need > to design how heap fragmentation plays a role in that and make sure that > you have the memory available that you think you have. Static memory allocation works great when your memory requirements are known upfront. However, there are applications where the memory requirements are not known upfront. In other words, in one case you may need to allocate 1k to ObjectA and 2k to ObjectB. In another situation, you need 0.5k for ObjectA, 3k for ObjectB, and 2k for ObjectC. You get the point. So what solutions are available that avoid static memory allocation? The most straightforward way is to determine the maximum amount of RAM you need per object type, and allocate it at design time. This approach is wasteful, because you end up having to use a chip with more RAM than you actually need, or crippling the program's features/performance. Or, you can create arcane custom solutions to "emulate" dynamic memory allocation. With dynamic allocation, each object is allocated only as much RAM as it needs, and when the object is no longer needed the RAM can be freed and made available for other objects. Obviously we're not talking about PIC12Fs here. You need a device with enough resources to make effective use of DA. Vitaliy -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist