If you want to store data I would suggest using the Flash memory.
If you want to Buffer the incomming data from the serial port for a short time the adl_memGet function would work well.
Flash is not suitable for rapidly-changing data; use the Flash only if you need to store it permanently.
Beware that dynamic allocation is often best avoided in embedded systems - why do you specifically want to use dynamic allocation?
Read the “Memory Service” section in the ADL User Guide for details of the dynamic allocation facilies provided by Open-AT.
Good question!
And what, exactly, do you mean by “store” - do you mean long-term, non-volatile storage (as charlvz seems to be assuming), or just short-term buffering?
The biggest single reason is: what will you do if your dynamic allocation request fails?
You must never simply assume at adl_memGet (or wahtever) will “just work” - you must check the return value for success, and have some sensible recovery strategy when it indicates a failure.
On a desktop system, it is easy to just put up an error box saying, “insufficient memory” - but an embedded system can’t do that!
Other reasons are that it adds overheads, and introduces the risk of memory leaks.
Definitely the former.
You are asking for 1000 bytes of memory whichever way you do it: so you need to ensure that 1000 bytes of memory will always be available for that call - so you might just as well allocate it statically in the first place!
I’ve seen problems when making static allocation of large buffers. Something like 60 Kb is the limit. If using dynamic allocation the limit is much bigger, but after 300-400 Kb we encountered problems again (Q2686H and OASIS 7.4).