How can I increase the heap size?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
MaGr_2160016
Level 4
Level 4
First like received First like given

I was wondering how increasing the heap size.

While I can see the symbols in the map I could find any useful reference to the linker's parameters.

Thanks,

-Marco G.

0 Likes
9 Replies
MaGr_2160016
Level 4
Level 4
First like received First like given

Incidentally, I found everything more stable if I avoid use of malloc()/calloc().

-Marco G.

0 Likes
Anonymous
Not applicable

You cannot increase the heap size as it is automatically set to consume all the memory not allocated to static objects. We recommend avoiding malloc where possible and if required to malloc structures of variables rather than malloc individual variables.

0 Likes

Thank you for reminding me of how the heap is allocated and confirming that in fact there are issues with the use of malloc().

-Marco G.

0 Likes

I hate to bring this up but I have wiced_hostname_lookup() occasionally and inexplicably, failing. I checked the code and it uses malloc(). Any possible relationship?

Thanks,

-Marco G.

0 Likes
Anonymous
Not applicable

A failed call to malloc() may the cause of your problems. You should run your application while running the debugger and investigate the root cause when it fails. Using wiced_assert() liberally will have your program break when the error condition occurs minimizing the effort required.

0 Likes

I removed the only malloc and I don't really have problems. The only call that fails is the wiced_dns resolver that sometimes returns what it looks like a random IP address.

Sent from my iPad

0 Likes
Félix_T
Level 5
Level 5
10 sign-ins First comment on blog 50 replies posted

Depending on the the IP stack you use the heap size can be changed.  We use LWIP with an RTOS that is not packaged with WICED.  To do this, we changed #define MEM_SIZE in opt.h and then changed the definition for mem_init, mem_free, and mem_malloc to call our OS supported memory functions which in turn use a memory pool set by the size of MEM_SIZE at compile time.

Also had to turn on MEM_LIBC_MALLOC, MEMP_MEM_MALLOC and force MEM_ALIGNMENT to 4.

0 Likes
GregG_16
Employee
Employee
50 sign-ins 25 sign-ins 25 comments on KBA

If this is still an issue, maybe it is best to start a new discussion?

0 Likes

Definitely not an issue.

Thanks,

-Marco G.