Memory Limit

Hi all,
I’m working with a new Fastrack Supreme 20

I’d like to know how much memory can I allocate width the command

adl_memGet ( )

I’d like to know if, with it, I take memory from the heap o stack memory space,
or if i take block from other memory space.

I’ve read that the modem has about 32M of RAM … I’d like to store serial data to
it … is it possible ?



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.

For what reason are you storing data?

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?

Hi Awneil

I don’t have much experience in memory allocation…Could you please explain why dynamic allocation should be avoided in embedded systems?

For a circular buffer for serial data, which of the following would you suggest:?
ascii Buffer[1000]


ascii* Buffer;
Buffer = adl_memGet(1000);

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!

thanks … but do you know somethink about the memory limits ?

Have you actually looked in the ADL User Guide?

It tells you there how to determine the available memory…

What i suppose to do if i need 125K data size?

Currently i am using adl_memget() function.

My application reading the data of meter which gives around 125K. This data will be sent once or twice in a month.

i’d call that long-term storage.

but is that 125Kbyte per reading? or over the total of one month?

It is instant reading not backup data of one month.

Check your compiler (GCC?) manual for any specific limitations, but there’s no fundamental reason why you can’t statically-allocate a 125K-byte array.

And what would you do if that call fails?

What - your meter gives 125K of data for one reading?! :open_mouth:

Yes, that is 90 days data stored in meter. After giving single command it gives whole data thro Uart.

That is the requirement of customer whenever they want they can request this data.

I am using this application since 2 months i never noticed this fail.

Till now i not handling this exception.

So you have an obvious failure mechanism built into your application just waiting to bite you!

That is a really, really Bad Idea!

What is the final resort?

Shall i make static allocation?

Here is memory info from adl_memGetInfo () of Q24+

Global Size=12282

That’s got to be the safest way unless you have some specific reason to use dynamic allocation.

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).

maximum size u can allocate dynamically is u16 ie. 65536 bytes. If you want more u have to make multiple allocations.


Sorry i my OS version it is U16.
Latest versions it is U32

Could you elaborate on that?

As noted by chiduprakash, if “something like 60K” is actually 64K - then that would indicate a 16-bit limitation somewhere.

Is it actually “something like” 60K bytes - or is it actually “something like” 60K elements in an array?