cancel
Showing results for 
Search instead for 
Did you mean: 

WICED Studio Wi-Fi Combo

Anonymous
Not applicable

Hi all:

I am trying to reconnect after MQTT disconnected.After several times successful reconnection and I can't reconnect any more. So I print the "_eheap-sbrk_heap_top " to check to RAM size I left everytime I make reconnection . I found it will reduce about 8-12K ram every time I reconnect success. So that may expand how my situation appear . I think it should be the problem of  “Recycling resources” part .I hope the team can explain that.

here is my mqtt connect function.

/*

* Open a connection and wait for MQTT_REQUEST_TIMEOUT period to receive a connection open OK event

*/

wiced_result_t aws_mqtt_conn_open( wiced_mqtt_object_t mqtt_obj, wiced_mqtt_callback_t callback )

{

    wiced_result_t            ret = WICED_SUCCESS;

    wiced_interface_t         interface = WICED_STA_INTERFACE;

    do {

    wiced_hostname_lookup( aws_app_info->region, &broker_address, 10000 );

    wiced_rtos_delay_milliseconds( 100 );

    }

    while(GET_IPV4_ADDRESS(broker_address)==0);

  WPRINT_APP_INFO(("[MQTT] Connecting to broker %u.%u.%u.%u ...\n\n", (uint8_t)(GET_IPV4_ADDRESS(broker_address) >> 24),

  (uint8_t)(GET_IPV4_ADDRESS(broker_address) >> 16),

  (uint8_t)(GET_IPV4_ADDRESS(broker_address) >> 8),

  (uint8_t)(GET_IPV4_ADDRESS(broker_address) >> 0)));

    wiced_mqtt_init( aws_app_info->mqtt_object );

    WPRINT_APP_INFO(("[MQTT] Connecting to MQTT Broker...\n"));

    ret = wiced_mqtt_connect( mqtt_obj, &broker_address, interface, callback, &security, &conninfo );

    if ( ret != WICED_SUCCESS )

    {

        WPRINT_APP_ERROR(("[MQTT] Failed to connect MQTT Broker\n"));

        ret = WICED_ERROR;

        goto _AWS_MQTT_CONN_OPEN_END;

    }

    if ( mqtt_wait_for( WICED_MQTT_EVENT_TYPE_CONNECT_REQ_STATUS, MQTT_REQUEST_TIMEOUT ) != WICED_SUCCESS )

    {

        WPRINT_APP_ERROR(("[MQTT] Failed to connect MQTT Broker\n"));

        ret = WICED_ERROR;

        goto _AWS_MQTT_CONN_OPEN_END;

    }

    WPRINT_APP_INFO(("[MQTT] Successfully connected MQTT Broker\n"));

_AWS_MQTT_CONN_OPEN_END:

    return ret;

}

do

  {

  ret = aws_mqtt_conn_open( app_info.mqtt_object, mqtt_connection_event_cb );

  connection_retries++ ;

  host_rtos_delay_milliseconds( 1000 );

  } while ( ( ret != WICED_SUCCESS ) && ( connection_retries < WICED_MQTT_CONNECTION_NUMBER_OF_RETRIES ) );

0 Likes
12 Replies
Anonymous
Not applicable
0 Likes
GauravS_31
Moderator
Moderator

Which version of Wiced SDK are you currently using? In which platform(s) are you getting this problem? After how many MQTT connect-disconnect cycles do you face this issue? I modified the project bluemix_iot to have only MQTT connect-disconnect cycles but I could not reproduce this issue. It would always reconnect successfully. I tested this project in Wiced Studio 4.1 in BCM4343W_AVN. I used the below statements before and after wiced_mqtt_connect()

mi = mallinfo();

printf("sbrk heap size:    %7lu\n", (uint32_t)_eheap - (uint32_t)_heap);

printf("sbrk current free: %7lu \n", (uint32_t)_eheap - (uint32_t)sbrk_heap_top);

printf("malloc allocated:  %7d\n", mi.uordblks);

printf("malloc free:       %7d\n", mi.fordblks);

printf("\ntotal free memory: %7lu\n", mi.fordblks + (uint32_t)_eheap - (uint32_t)sbrk_heap_top);

where the variables were defined as:

extern unsigned char _eheap[];

extern unsigned char *sbrk_heap_top;

volatile struct mallinfo mi;

The statements consistently returned the following print output before and after wiced_mqtt_connect()

sbrk heap size:      98340

sbrk current free:   65528

malloc allocated:    26900

malloc free:          5912

total free memory:   71440

This means that the RAM memory size did not change after reconnection. Can you please provide the code where you actually check the RAM size after reconnection? I need to be able to reproduce this problem. Also do you allocate memory for MQTT object every time you make a reconnection?

0 Likes
Anonymous
Not applicable

Thanks for your reply @grsr.

I am using WICED studio 4.1/WICED SDK 3.5.2 and BCM43438.

I have this problem every time I make MQTT connection.

I check the RAM size with command "WPRINT_APP_INFO( ("Free heep: %d\n", (_eheap-sbrk_heap_top)) );"

I defined all the Object about MQTT as GROBLE

static aws_app_info_t *aws_app_info;

static wiced_ip_address_t broker_address;

static wiced_mqtt_pkt_connect_t  conninfo;

static wiced_mqtt_security_t     security;

static platform_dct_security_t*  dct_security = NULL;

static aws_app_info_t  app_info;

0 Likes
Anonymous
Not applicable

I can't find the bluemix_iot project,where is it?

0 Likes
AxLi_1746341
Honored Contributor

jackson_lv wrote:

I can't find the bluemix_iot project,where is it?

WICED IBM IoT Bluemix quickstart

0 Likes
user_1989521
New Contributor II

HI Cypress Team,

I can confirm memory leak problem mentioned by jackson_lv in SDK 4.1.

Below you can find listing of calls for MQTT open and MQTT close routines (2 full cycles MQTT open-close) and info about mem allocation (malloc_info_command).

As you can see some MQTT close routine (probably mqtt_network_disconnect) do not release all allocated memory by some MQTT open routine (probably mqtt_network_connect).

wiced_result_t mqtt_network_connect( mqtt_socket_t *socket )

{

    return wiced_tcp_connect( &socket->socket, &socket->server_ip_address, socket->portnumber, WICED_MQTT_CONNECTION_TIMEOUT );

}

==> allocates about 3kB of RAM but mqtt_network_disconnect (wiced_tcp_disconnect) do not release this allocated memory, so each open-close cycle "eats" 3120 bytes up to "out of memory" event or hang-on system or watchdog reset.

Detailed analyze of wiced_tcp_connect() function indicates that this 3kB of RAM is allocated by wiced_tcp_start_tls() sub-routine. Question is: which closing routine is releasing memory allocated by wiced_tcp_start_tls ?

It is very easy to find and check, so why up to now you have not a solution of problem or some workaround ?

Robert

ARENAALLOCATEDNON-INUSETOP-MOSTdARENAdALLOCLEAK
wiced_hostname_lookup
###### mqtt_network_init / mqtt_network_init2775626900856856
###### mqtt_network_init / wiced_tcp_create_socket277562690085685600
###### mqtt_network_init / wiced_tls_init_root_ca_certificates31852291482704270440962248
###### mqtt_network_init / wiced_tls_init_identity40044317408304525681922592
###### mqtt_network_init / wiced_tls_init_context40044317408304525600
###### mqtt_network_init / wiced_tcp_enable_tls40044317408304525600
###### mqtt_network_init / mqtt_network_connect44140348449296473640963104
###### mqtt_network_init / wiced_tcp_register_callbacks44140348449296473600
MQTT connection opened44140348449296473600
###### mqtt_network_deinit / mqtt_network_deinit44140348449296473600
###### mqtt_network_deinit / wiced_tcp_unregister_callbacks44140348449296473600
###### mqtt_network_deinit / mqtt_network_disconnect44140348449296473600
###### mqtt_network_deinit / wiced_tls_reset_context44140327881135247360-2056
###### mqtt_network_deinit / wiced_tls_deinit_root_ca_certificates44140300201412081280-2768
###### mqtt_network_deinit / wiced_tcp_delete_socket441403002014120812800
MQTT connection closed441403002014120812800-3120
wiced_hostname_lookup441403002014120812800
###### mqtt_network_init / mqtt_network_init441403002014120812800
###### mqtt_network_init / wiced_tcp_create_socket441403002014120812800
###### mqtt_network_init / wiced_tls_init_root_ca_certificates441403226811872812802248
###### mqtt_network_init / wiced_tls_init_identity44140348609280601602592
###### mqtt_network_init / wiced_tls_init_context44140348609280601600
###### mqtt_network_init / wiced_tcp_enable_tls44140348609280601600
###### mqtt_network_init / mqtt_network_connect482363797210264549640963112
###### mqtt_network_init / wiced_tcp_register_callbacks482363797210264549600
MQTT connection opened482363797210264549600
###### mqtt_network_deinit / mqtt_network_deinit482363797210264549600
###### mqtt_network_deinit / wiced_tcp_unregister_callbacks482363797210264549600
###### mqtt_network_deinit / mqtt_network_disconnect482363797210264549600
###### mqtt_network_deinit / wiced_tls_reset_context48236359081232854960-2064
###### mqtt_network_deinit / wiced_tls_deinit_root_ca_certificates48236331401509688880-2768
###### mqtt_network_deinit / wiced_tcp_delete_socket482363314015096888800
MQTT connection closed482363314015096888800-3120
0 Likes
user_1989521
New Contributor II

Hi Cypress,

The results of further investigation:

wiced_mqtt_connect -> mqtt_connection_init -> mqtt_network_init -> mqtt_network_connect -> wiced_tcp_connect (NetX_Duo) -> wiced_tcp_start_tls -> wiced_generic_start_tls_with_ciphers -> ssl_handshake_client_async

ssl_handshake_client_async( &tls_context->context ) allocates memory block but ssl_free(&tls_context->context) releases smaller memory block = MEMORY LEAK !

Beacuse SSL library is closed type, we can not correct that bug and another problems. It seems that BESL memory leak problems has long story (about 2 years) and up to now still not solved!

When you will provide useful BESL library?

Robert

AxLi_1746341
Honored Contributor

You probably want to test sdk-4.1.1.

0 Likes
user_1989521
New Contributor II

SDK 4.1.1.8 tested - problem still remain !

SDK 4.1.1.8ARENAALLOCATEDNON-INUSETOP-MOSTdARENAdALLOCLEAK
wiced_hostname_lookup
MQTT connection opened441443484093044744163847944
MQTT connection closed44144300161412881360-4824-3120
user_1989521
New Contributor II

The newest SDK 4.1.1.8 - few MQTT open-close cycles and MQTT connection open error (out of memory)

Starting WICED v4.1.1Platform BCM94343W_AVN initialisedStarted ThreadX v5.6Initialising NetX_Duo v5.7_sp2Creating Packet poolsWWD SDIO interface initialisedWLAN MAC Address : B0:38:29:3D:3A:39
WLAN Firmware    : wl0: Jan 10 2017 19:57:03 version 7.45.98.6 (r663489) FWID 01-cf6f763a
wiced_initmalloc_info {
arena:   19568; /* total space allocated from system */
ordblks:     1; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 14776; /* total allocated space */
fordblks: 4792; /* total non-inuse space */
keepcost: 4792; /* top-most, releasable (via malloc_trim) space */
};
Joining : HOTSPOT2016Successfully joined : HOTSPOT2016Obtaining IPv4 address via DHCPDHCP CLIENT hostname WICED IPIPv4 network ready IP: 192.168.1.158Setting IPv6 link-local addressIPv6 network ready IP: FE80:0000:0000:0000:B238:29FF:FE3D:3A39join_WIFI()malloc_info {
arena:   19568; /* total space allocated from system */
ordblks:     1; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 14776; /* total allocated space */
fordblks: 4792; /* total non-inuse space */
keepcost: 4792; /* top-most, releasable (via malloc_trim) space */
};
mqtt_object = (wiced_mqtt_object_t) mallocmalloc_info {
arena:   27760; /* total space allocated from system */
ordblks:     1; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 20096; /* total allocated space */
fordblks: 7664; /* total non-inuse space */
keepcost: 7664; /* top-most, releasable (via malloc_trim) space */
};
wiced_mqtt_initmalloc_info {
arena:   27760; /* total space allocated from system */
ordblks:     1; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 26896; /* total allocated space */
fordblks:   864; /* total non-inuse space */
keepcost:   864; /* top-most, releasable (via malloc_trim) space */
};
resource_get_readonly_buffermalloc_info {
arena:   27760; /* total space allocated from system */
ordblks:     1; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 26896; /* total allocated space */
fordblks:   864; /* total non-inuse space */
keepcost:   864; /* top-most, releasable (via malloc_trim) space */
};
resource_get_readonly_buffermalloc_info {
arena:   27760; /* total space allocated from system */
ordblks:     1; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 26896; /* total allocated space */
fordblks:   864; /* total non-inuse space */
keepcost:   864; /* top-most, releasable (via malloc_trim) space */
};
resource_get_readonly_buffermalloc_info {
arena:   27760; /* total space allocated from system */
ordblks:     1; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 26896; /* total allocated space */
fordblks:   864; /* total non-inuse space */
keepcost:   864; /* top-most, releasable (via malloc_trim) space */
};
Resolved Broker IP: 54.87.173.19
wiced_hostname_lookupmalloc_info {
arena:   27760; /* total space allocated from system */
ordblks:     1; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 26896; /* total allocated space */
fordblks:   864; /* total non-inuse space */
keepcost:   864; /* top-most, releasable (via malloc_trim) space */
};
MQTT connection opened mqtt_conn_openmalloc_info {
arena:   44144; /* total space allocated from system */
ordblks:     8; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 34840; /* total allocated space */
fordblks: 9304; /* total non-inuse space */
keepcost: 4744; /* top-most, releasable (via malloc_trim) space */
};
MQTT connection closed mqtt_conn_closemalloc_info {
arena:   44144; /* total space allocated from system */
ordblks:     6; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 30016; /* total allocated space */
fordblks: 14128; /* total non-inuse space */
keepcost: 8136; /* top-most, releasable (via malloc_trim) space */
};
Resolved Broker IP: 52.44.116.179
wiced_hostname_lookupmalloc_info {
arena:   44144; /* total space allocated from system */
ordblks:     6; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 30016; /* total allocated space */
fordblks: 14128; /* total non-inuse space */
keepcost: 8136; /* top-most, releasable (via malloc_trim) space */
};
MQTT connection opened mqtt_conn_openmalloc_info {
arena:   48240; /* total space allocated from system */
ordblks:    10; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 37968; /* total allocated space */
fordblks: 10272; /* total non-inuse space */
keepcost: 5504; /* top-most, releasable (via malloc_trim) space */
};
MQTT connection closed mqtt_conn_closemalloc_info {
arena:   48240; /* total space allocated from system */
ordblks:    11; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 33136; /* total allocated space */
fordblks: 15104; /* total non-inuse space */
keepcost: 8896; /* top-most, releasable (via malloc_trim) space */
};
Resolved Broker IP: 52.0.119.10
wiced_hostname_lookupmalloc_info {
arena:   48240; /* total space allocated from system */
ordblks:    11; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 33136; /* total allocated space */
fordblks: 15104; /* total non-inuse space */
keepcost: 8896; /* top-most, releasable (via malloc_trim) space */
};
MQTT connection opened mqtt_conn_openmalloc_info {
arena:   52336; /* total space allocated from system */
ordblks:    10; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 41120; /* total allocated space */
fordblks: 11216; /* total non-inuse space */
keepcost: 6464; /* top-most, releasable (via malloc_trim) space */
};
MQTT connection closed mqtt_conn_closemalloc_info {
arena:   52336; /* total space allocated from system */
ordblks:    14; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 36280; /* total allocated space */
fordblks: 16056; /* total non-inuse space */
keepcost: 9856; /* top-most, releasable (via malloc_trim) space */
};
Resolved Broker IP: 52.44.116.179
wiced_hostname_lookupmalloc_info {
arena:   52336; /* total space allocated from system */
ordblks:    14; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 36280; /* total allocated space */
fordblks: 16056; /* total non-inuse space */
keepcost: 9856; /* top-most, releasable (via malloc_trim) space */
};
MQTT connection opened mqtt_conn_openmalloc_info {
arena:   52336; /* total space allocated from system */
ordblks:    13; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 44240; /* total allocated space */
fordblks: 8096; /* total non-inuse space */
keepcost: 3136; /* top-most, releasable (via malloc_trim) space */
};
MQTT connection closed mqtt_conn_closemalloc_info {
arena:   52336; /* total space allocated from system */
ordblks:    16; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 39408; /* total allocated space */
fordblks: 12928; /* total non-inuse space */
keepcost: 6544; /* top-most, releasable (via malloc_trim) space */
};
Resolved Broker IP: 54.164.39.189
wiced_hostname_lookupmalloc_info {
arena:   52336; /* total space allocated from system */
ordblks:    16; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 39408; /* total allocated space */
fordblks: 12928; /* total non-inuse space */
keepcost: 6544; /* top-most, releasable (via malloc_trim) space */
};
MQTT connection opened mqtt_conn_openmalloc_info {
arena:   56432; /* total space allocated from system */
ordblks:    15; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 47376; /* total allocated space */
fordblks: 9056; /* total non-inuse space */
keepcost: 3784; /* top-most, releasable (via malloc_trim) space */
};
MQTT connection closed mqtt_conn_closemalloc_info {
arena:   56432; /* total space allocated from system */
ordblks:    20; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 42536; /* total allocated space */
fordblks: 13896; /* total non-inuse space */
keepcost: 7176; /* top-most, releasable (via malloc_trim) space */
};
Resolved Broker IP: 52.2.5.154
wiced_hostname_lookupmalloc_info {
arena:   56432; /* total space allocated from system */
ordblks:    20; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 42536; /* total allocated space */
fordblks: 13896; /* total non-inuse space */
keepcost: 7176; /* top-most, releasable (via malloc_trim) space */
};
MQTT connection opened mqtt_conn_openmalloc_info {
arena:   60528; /* total space allocated from system */
ordblks:    17; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 50520; /* total allocated space */
fordblks: 10008; /* total non-inuse space */
keepcost: 4552; /* top-most, releasable (via malloc_trim) space */
};
MQTT connection closed mqtt_conn_closemalloc_info {
arena:   60528; /* total space allocated from system */
ordblks:    23; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 45672; /* total allocated space */
fordblks: 14856; /* total non-inuse space */
keepcost: 7944; /* top-most, releasable (via malloc_trim) space */
};
Resolved Broker IP: 54.164.39.189
wiced_hostname_lookupmalloc_info {
arena:   60528; /* total space allocated from system */
ordblks:    23; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 45672; /* total allocated space */
fordblks: 14856; /* total non-inuse space */
keepcost: 7944; /* top-most, releasable (via malloc_trim) space */
};
MQTT connection opened mqtt_conn_openmalloc_info {
arena:   64624; /* total space allocated from system */
ordblks:    19; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 53664; /* total allocated space */
fordblks: 10960; /* total non-inuse space */
keepcost: 5320; /* top-most, releasable (via malloc_trim) space */
};
MQTT connection closed mqtt_conn_closemalloc_info {
arena:   64624; /* total space allocated from system */
ordblks:    26; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 48808; /* total allocated space */
fordblks: 15816; /* total non-inuse space */
keepcost: 8712; /* top-most, releasable (via malloc_trim) space */
};
Resolved Broker IP: 52.2.5.154
wiced_hostname_lookupmalloc_info {
arena:   64624; /* total space allocated from system */
ordblks:    26; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 48808; /* total allocated space */
fordblks: 15816; /* total non-inuse space */
keepcost: 8712; /* top-most, releasable (via malloc_trim) space */
};
MQTT connection open error 4mqtt_conn_openmalloc_info {
arena:   64624; /* total space allocated from system */
ordblks:    27; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 49328; /* total allocated space */
fordblks: 15296; /* total non-inuse space */
keepcost: 2512; /* top-most, releasable (via malloc_trim) space */
};
mqtt_conn_closemalloc_info {
arena:   64624; /* total space allocated from system */
ordblks:    27; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 49328; /* total allocated space */
fordblks: 15296; /* total non-inuse space */
keepcost: 2512; /* top-most, releasable (via malloc_trim) space */
};
Resolved Broker IP: 52.0.119.10
wiced_hostname_lookupmalloc_info {
arena:   64624; /* total space allocated from system */
ordblks:    27; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 49328; /* total allocated space */
fordblks: 15296; /* total non-inuse space */
keepcost: 2512; /* top-most, releasable (via malloc_trim) space */
};
MQTT connection open error 4mqtt_conn_openmalloc_info {
arena:   64624; /* total space allocated from system */
ordblks:    27; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 49328; /* total allocated space */
fordblks: 15296; /* total non-inuse space */
keepcost: 2512; /* top-most, releasable (via malloc_trim) space */
};
mqtt_conn_closemalloc_info {
arena:   64624; /* total space allocated from system */
ordblks:    27; /* number of non-inuse chunks */
smblks:      0; /* unused -- always zero */
hblks:       0; /* number of mmapped regions */
hblkhd:      0; /* total space in mmapped regions */
usmblks:     0; /* unused -- always zero */
fsmblks:     0; /* unused -- always zero */
uordblks: 49328; /* total allocated space */
fordblks: 15296; /* total non-inuse space */
keepcost: 2512; /* top-most, releasable (via malloc_trim) space */
};

user_1989521
New Contributor II

found some bug in mqtt_network_deinit() /mqtt_network.c file/ -> missing wiced_tls_deinit_indentity()...

below fix:

wiced_result_t mqtt_network_deinit( mqtt_socket_t *socket )

{

    wiced_tcp_unregister_callbacks( &socket->socket );

    mqtt_network_disconnect( socket );

    if ( socket->socket.tls_context != NULL )

    {

        wiced_tls_reset_context( socket->socket.tls_context );

        wiced_tls_deinit_identity( &socket->tls_identity ); // add this call

    }

    if ( socket->socket.tls_context != NULL )

    {

        wiced_tls_deinit_root_ca_certificates( );

    }

    wiced_tcp_delete_socket( &socket->socket );

    return WICED_SUCCESS;

}

then MQTT open-close cycles without memory leak:

Resolved Broker IP: 54.164.39.189

wiced_hostname_lookup

malloc_info {

  arena:   44144; /* total space allocated from system */

  ordblks:    1; /* number of non-inuse chunks */

  smblks:      0; /* unused -- always zero */

  hblks:      0; /* number of mmapped regions */

  hblkhd:      0; /* total space in mmapped regions */

  usmblks:    0; /* unused -- always zero */

  fsmblks:    0; /* unused -- always zero */

  uordblks: 26896; /* total allocated space */

  fordblks: 17248; /* total non-inuse space */

  keepcost: 17248; /* top-most, releasable (via malloc_trim) space */

};

MQTT connection opened

mqtt_conn_open

malloc_info {

  arena:   44144; /* total space allocated from system */

  ordblks:    8; /* number of non-inuse chunks */

  smblks:      0; /* unused -- always zero */

  hblks:      0; /* number of mmapped regions */

  hblkhd:      0; /* total space in mmapped regions */

  usmblks:    0; /* unused -- always zero */

  fsmblks:    0; /* unused -- always zero */

  uordblks: 34840; /* total allocated space */

  fordblks: 9304; /* total non-inuse space */

  keepcost: 4744; /* top-most, releasable (via malloc_trim) space */

};

MQTT connection closed

mqtt_conn_close

malloc_info {

  arena:   44144; /* total space allocated from system */

  ordblks:    1; /* number of non-inuse chunks */

  smblks:      0; /* unused -- always zero */

  hblks:      0; /* number of mmapped regions */

  hblkhd:      0; /* total space in mmapped regions */

  usmblks:    0; /* unused -- always zero */

  fsmblks:    0; /* unused -- always zero */

  uordblks: 26896; /* total allocated space */

  fordblks: 17248; /* total non-inuse space */

  keepcost: 17248; /* top-most, releasable (via malloc_trim) space */

};

Resolved Broker IP: 52.44.116.179

wiced_hostname_lookup

malloc_info {

  arena:   44144; /* total space allocated from system */

  ordblks:    1; /* number of non-inuse chunks */

  smblks:      0; /* unused -- always zero */

  hblks:      0; /* number of mmapped regions */

  hblkhd:      0; /* total space in mmapped regions */

  usmblks:    0; /* unused -- always zero */

  fsmblks:    0; /* unused -- always zero */

  uordblks: 26896; /* total allocated space */

  fordblks: 17248; /* total non-inuse space */

  keepcost: 17248; /* top-most, releasable (via malloc_trim) space */

};

MQTT connection opened

mqtt_conn_open

malloc_info {

  arena:   44144; /* total space allocated from system */

  ordblks:    8; /* number of non-inuse chunks */

  smblks:      0; /* unused -- always zero */

  hblks:      0; /* number of mmapped regions */

  hblkhd:      0; /* total space in mmapped regions */

  usmblks:    0; /* unused -- always zero */

  fsmblks:    0; /* unused -- always zero */

  uordblks: 34840; /* total allocated space */

  fordblks: 9304; /* total non-inuse space */

  keepcost: 4744; /* top-most, releasable (via malloc_trim) space */

};

MQTT connection closed

mqtt_conn_close

malloc_info {

  arena:   44144; /* total space allocated from system */

  ordblks:    1; /* number of non-inuse chunks */

  smblks:      0; /* unused -- always zero */

  hblks:      0; /* number of mmapped regions */

  hblkhd:      0; /* total space in mmapped regions */

  usmblks:    0; /* unused -- always zero */

  fsmblks:    0; /* unused -- always zero */

  uordblks: 26896; /* total allocated space */

  fordblks: 17248; /* total non-inuse space */

  keepcost: 17248; /* top-most, releasable (via malloc_trim) space */

};

Resolved Broker IP: 54.87.173.19

wiced_hostname_lookup

malloc_info {

  arena:   44144; /* total space allocated from system */

  ordblks:    1; /* number of non-inuse chunks */

  smblks:      0; /* unused -- always zero */

  hblks:      0; /* number of mmapped regions */

  hblkhd:      0; /* total space in mmapped regions */

  usmblks:    0; /* unused -- always zero */

  fsmblks:    0; /* unused -- always zero */

  uordblks: 26896; /* total allocated space */

  fordblks: 17248; /* total non-inuse space */

  keepcost: 17248; /* top-most, releasable (via malloc_trim) space */

};

MQTT connection opened

mqtt_conn_open

malloc_info {

  arena:   44144; /* total space allocated from system */

  ordblks:    8; /* number of non-inuse chunks */

  smblks:      0; /* unused -- always zero */

  hblks:      0; /* number of mmapped regions */

  hblkhd:      0; /* total space in mmapped regions */

  usmblks:    0; /* unused -- always zero */

  fsmblks:    0; /* unused -- always zero */

  uordblks: 34840; /* total allocated space */

  fordblks: 9304; /* total non-inuse space */

  keepcost: 4744; /* top-most, releasable (via malloc_trim) space */

};

MQTT connection closed

mqtt_conn_close

malloc_info {

  arena:   44144; /* total space allocated from system */

  ordblks:    1; /* number of non-inuse chunks */

  smblks:      0; /* unused -- always zero */

  hblks:      0; /* number of mmapped regions */

  hblkhd:      0; /* total space in mmapped regions */

  usmblks:    0; /* unused -- always zero */

  fsmblks:    0; /* unused -- always zero */

  uordblks: 26896; /* total allocated space */

  fordblks: 17248; /* total non-inuse space */

  keepcost: 17248; /* top-most, releasable (via malloc_trim) space */

};

Anonymous
Not applicable

Thanks a lot purchasing_1989521​. I will test it later!

0 Likes