Memory Fragmentation

HolgerLembke
Posts: 3
Joined: Thu Jun 18, 2015 1:13 am

Memory Fragmentation

Postby HolgerLembke » Thu Jun 18, 2015 1:18 am

Hi,

I'm currently investigation the effects of memory fragmentation on the heap.

As far as I see, there is no documentation about pvPortMalloc() and the structures how the free list is managed.

Is there any way to get these details?

ESP_Faye
Posts: 1627
Joined: Mon Oct 27, 2014 11:08 am

Re: Memory Fragmentation

Postby ESP_Faye » Thu Jun 18, 2015 11:06 am

Hi,

Please using "os_malloc" which is same as "malloc", you can refer to IOT_Demo

Thanks for your interest in ESP8266 !

HolgerLembke
Posts: 3
Joined: Thu Jun 18, 2015 1:13 am

Re: Memory Fragmentation

Postby HolgerLembke » Thu Jun 18, 2015 3:04 pm

I rephrase my question:

Are there informations available about how memory management works internally?

ESP_Faye
Posts: 1627
Joined: Mon Oct 27, 2014 11:08 am

Re: Memory Fragmentation

Postby ESP_Faye » Tue Jun 23, 2015 3:34 pm

Hi,

Sorry for the misunderstanding..

About memory management we recommended you to use esp_iot_rtos_sdk which using freeRTOS https://github.com/espressif/esp_iot_rtos_sdk, source code of memory management is \esp_iot_rtos_sdk-master\third_party\freertos\heap_4.c

Thanks for your interest in ESP8266 !

HolgerLembke
Posts: 3
Joined: Thu Jun 18, 2015 1:13 am

Re: Memory Fragmentation

Postby HolgerLembke » Wed Jun 24, 2015 1:49 am

Thank you for your reply. I already tried to follow the source in heap_4.c but it seems to me, that espressif did some modifications to this routines. At least I can't follow the memory heap structure with it.

So I'm curios whether there are changes to that manager or not.

Thank you!

EliteScientist
Posts: 10
Joined: Sat Nov 21, 2015 5:08 pm

Re: Memory Fragmentation

Postby EliteScientist » Wed Nov 25, 2015 4:44 pm

Is there any way to access os_malloc and os_free within the RTOS SDK? Maybe change the heap management to os_ instead of using the heap_4.c in freertos?

I ask because my app does dynamic memory allocation to parse incoming data, It receives quite a bit of packets. Randomly I'll get a Fatal Exception which occurs in the pvPortRealloc method. I don't have any code that uses realloc.

My printf traces are:

Disposing Grid
Avaliable - Attepting To Send: 61 bytes - Fatal exception (28):
epc1=0x4010168a
epc2=0x00000000
epc3=0x4010179e
epcvaddr=0x00000000
depc=0x00000000
rtn_add=0x40101511

ets Jan 8 2013,rst cause:2, boot mode:(3,6)


Its attempting to send 61 bytes via espconn_send(); then I get the fatal exception:

epc1 is in the pvPortRealloc Method.
epc3 is in the vPortExitCritical Method.


In previous cases, I've fixed fatal exceptions by reusing memory using memset to clear it, instead of free and malloc'ing a new pointer.

electronicsguy
Posts: 7
Joined: Mon Jun 22, 2015 1:10 pm

Re: Memory Fragmentation

Postby electronicsguy » Wed Dec 07, 2016 2:25 pm

@EliteScientist and @HolgerLembke did you guys get any more info on the custom malloc routines implemented? Any way to hook into them to get more information? your reply will be very appreciated. Thanks.

Who is online

Users browsing this forum: Bing [Bot] and 10 guests