This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C1294NCPDT: LWIP server stops working after a few seconds

Part Number: TM4C1294NCPDT
Other Parts Discussed in Thread: EK-TM4C1294XL,

Hello

I working in a LWIP server and I use the FreeRTOS and Tivaware 2.1.3.156 in this project.

I create an html page to display some values via ssi tags. This page is automatically refreshed every 1 second, via meta tag in html:

 <meta http-equiv="refresh" content="2" />

After a few seconds, the server stops working. But when a remove the automatically refresh, the issue ocurrs in a few hours.

I try to make it in the enet_io example, but the same issue ocurrs.

This is the my lwipops.h file:

//*****************************************************************************
//
// lwipopts.h - Configuration file for lwIP
//
// Copyright (c) 2013-2016 Texas Instruments Incorporated.  All rights reserved.
// Software License Agreement
// 
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
// 
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
// 
// This is part of revision 2.1.3.156 of the EK-TM4C1294XL Firmware Package.
//
//*****************************************************************************
//
// NOTE:  This file has been derived from the lwIP/src/include/lwip/opt.h
// header file.
//
// For additional details, refer to the original "opt.h" file, and lwIP
// documentation.
//
//*****************************************************************************
#ifndef __LWIPOPTS_H__
#define __LWIPOPTS_H__

#include <stdint.h>

//*****************************************************************************
//
// ---------- Stellaris / lwIP Port Options ----------
//
//*****************************************************************************
#define HOST_TMR_INTERVAL               10         // default is 0
//#define DHCP_EXPIRE_TIMER_MSECS         (60 * 1000)
#define LWIP_HTTPD_SSI 1
#define LWIP_HTTPD_CGI 1
#define LWIP_HTTPD_DYNAMIC_HEADERS 1
//#define EMAC_PHY_CONFIG EMAC_PHY_TYPE_EXTERNAL_RMII
//#define PHY_PHYS_ADDR      1
#define EMAC_PHY_CONFIG (EMAC_PHY_TYPE_INTERNAL | EMAC_PHY_INT_MDIX_EN |      \
                         EMAC_PHY_AN_100B_T_FULL_DUPLEX)
#define PHY_PHYS_ADDR      0
#define NUM_TX_DESCRIPTORS              8
#define NUM_RX_DESCRIPTORS 8

//*****************************************************************************
//
// ---------- Platform specific locking ----------
//
//*****************************************************************************
#define SYS_LIGHTWEIGHT_PROT            1           // default is 0
#define NO_SYS                          0           // default is 0
#if !NO_SYS
#define LWIP_COMPAT_MUTEX               1
#define RTOS_FREERTOS                   1
#endif /* !NO_SYS */
//#define MEMCPY(dst,src,len)             memcpy(dst,src,len)
//#define SMEMCPY(dst,src,len)            memcpy(dst,src,len)

//*****************************************************************************
//
// ---------- Memory options ----------
//
//*****************************************************************************
//#define MEM_LIBC_MALLOC                 0
#define MEM_ALIGNMENT                     4
#define MEM_SIZE                          (64 * 1024)
//#define MEMP_OVERFLOW_CHECK             0
//#define MEMP_SANITY_CHECK               0
//#define MEM_USE_POOLS                   0
//#define MEMP_USE_CUSTOM_POOLS           0

//*****************************************************************************
//
// ---------- Internal Memory Pool Sizes ----------
//
//*****************************************************************************
#define MEMP_NUM_PBUF                     16    // Default 16, was 16
//#define MEMP_NUM_RAW_PCB                4
//#define MEMP_NUM_UDP_PCB                4
#define MEMP_NUM_TCP_PCB                  40
//#define MEMP_NUM_TCP_PCB_LISTEN         8
//#define MEMP_NUM_TCP_SEG                16
//#define MEMP_NUM_REASSDATA              5
//#define MEMP_NUM_ARP_QUEUE              30
//#define MEMP_NUM_IGMP_GROUP             8
#define MEMP_NUM_SYS_TIMEOUT              10 //5
//#define MEMP_NUM_NETBUF                 2
//#define MEMP_NUM_NETCONN                4
//#define MEMP_NUM_TCPIP_MSG_API          8
//#define MEMP_NUM_TCPIP_MSG_INPKT        8
#define PBUF_POOL_SIZE                    64    // Default 16

//*****************************************************************************
//
// ---------- ARP options ----------
//
//*****************************************************************************
//#define LWIP_ARP                        1
//#define ARP_TABLE_SIZE                  10
//#define ARP_QUEUEING                    1
//#define ETHARP_TRUST_IP_MAC             1

//*****************************************************************************
//
// ---------- IP options ----------
//
//*****************************************************************************
//#define IP_FORWARD                      0
//#define IP_OPTIONS_ALLOWED              1
#define IP_REASSEMBLY                   0           // default is 1
#define IP_FRAG                         0           // default is 1
//#define IP_REASS_MAXAGE                 3
//#define IP_REASS_MAX_PBUFS              10
//#define IP_FRAG_USES_STATIC_BUF         1
//#define IP_FRAG_MAX_MTU                 1500
//#define IP_DEFAULT_TTL                  255

//*****************************************************************************
//
// ---------- ICMP options ----------
//
//*****************************************************************************
//#define LWIP_ICMP                       1
//#define ICMP_TTL                       (IP_DEFAULT_TTL)

//*****************************************************************************
//
// ---------- RAW options ----------
//
//*****************************************************************************
//#define LWIP_RAW                        1
//#define RAW_TTL                        (IP_DEFAULT_TTL)

//*****************************************************************************
//
// ---------- DHCP options ----------
//
//*****************************************************************************
#define LWIP_DHCP                       1           // default is 0
//#define DHCP_DOES_ARP_CHECK             ((LWIP_DHCP) && (LWIP_ARP))

//*****************************************************************************
//
// ---------- UPNP options ----------
//
//*****************************************************************************
//#define LWIP_UPNP                       0

//*****************************************************************************
//
// ---------- PTPD options ----------
//
//*****************************************************************************
//#define LWIP_PTPD                       0

//*****************************************************************************
//
// ---------- AUTOIP options ----------
//
//*****************************************************************************
#define LWIP_AUTOIP                     1           // default is 0
#define LWIP_DHCP_AUTOIP_COOP           ((LWIP_DHCP) && (LWIP_AUTOIP))
                                                    // default is 0
#define LWIP_DHCP_AUTOIP_COOP_TRIES     5           // default is 9

//*****************************************************************************
//
// ---------- SNMP options ----------
//
//*****************************************************************************
#define LWIP_SNMP                       1 // 0
#define SNMP_CONCURRENT_REQUESTS        1
#define SNMP_TRAP_DESTINATIONS          1
#define SNMP_PRIVATE_MIB                0
#define SNMP_SAFE_REQUESTS              1

//*****************************************************************************
//
// ---------- IGMP options ----------
//
//*****************************************************************************
//#define LWIP_IGMP                       0

//*****************************************************************************
//
// ---------- DNS options -----------
//
//*****************************************************************************
#define LWIP_DNS                        0
#define DNS_TABLE_SIZE                  4
#define DNS_MAX_NAME_LENGTH             256
#define DNS_MAX_SERVERS                 2
#define DNS_DOES_NAME_CHECK             1
#define DNS_USES_STATIC_BUF             1
#define DNS_MSG_SIZE                    512

//*****************************************************************************
//
// ---------- UDP options ----------
//
//*****************************************************************************
#define LWIP_UDP                        1
//#define LWIP_UDPLITE                    0
//#define UDP_TTL                         (IP_DEFAULT_TTL)

//*****************************************************************************
//
// ---------- TCP options ----------
//
//*****************************************************************************
#define LWIP_TCP                        1
//#define TCP_TTL                         (IP_DEFAULT_TTL)
#define TCP_WND                         4096   // default is 2048
//#define TCP_MAXRTX                      12
//#define TCP_SYNMAXRTX                   6
//#define TCP_QUEUE_OOSEQ                 1
#define TCP_MSS                        1500        // default is 128
//#define TCP_CALCULATE_EFF_SEND_MSS      1
#define TCP_SND_BUF                     (4 * TCP_MSS)
                                                    // default is 256, was 6 *
//#define TCP_SND_QUEUELEN                (4 * (TCP_SND_BUF/TCP_MSS))
//#define TCP_SNDLOWAT                    (TCP_SND_BUF/2)
//#define TCP_LISTEN_BACKLOG              0
//#define TCP_DEFAULT_LISTEN_BACKLOG      0xff

//*****************************************************************************
//
// ---------- API options ----------
//
//*****************************************************************************
//#define LWIP_EVENT_API                  0
//#define LWIP_CALLBACK_API               1

//*****************************************************************************
//
// ---------- Pbuf options ----------
//
//*****************************************************************************
#define PBUF_LINK_HLEN                  16          // default is 14
#define PBUF_POOL_BUFSIZE               512
                   // default is LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_HLEN)
#define ETH_PAD_SIZE                    0           // default is 0

//*****************************************************************************
//
// ---------- Network Interfaces options ----------
//
//*****************************************************************************
//#define LWIP_NETIF_HOSTNAME             0
//#define LWIP_NETIF_API                  0
//#define LWIP_NETIF_STATUS_CALLBACK      0
//#define LWIP_NETIF_LINK_CALLBACK        0
//#define LWIP_NETIF_HWADDRHINT           0

//*****************************************************************************
//
// ---------- LOOPIF options ----------
//
//*****************************************************************************
//#define LWIP_HAVE_LOOPIF                0
//#define LWIP_LOOPIF_MULTITHREADING      1

//*****************************************************************************
//
// ---------- Thread options ----------
//
//*****************************************************************************
#define TCPIP_THREAD_NAME              "tcpip"
#define TCPIP_THREAD_STACKSIZE          2048
#define TCPIP_THREAD_PRIO               14
#define TCPIP_MBOX_SIZE                 32
//#define SLIPIF_THREAD_NAME             "slipif_loop"
//#define SLIPIF_THREAD_STACKSIZE         0
//#define SLIPIF_THREAD_PRIO              1
//#define PPP_THREAD_NAME                "pppMain"
//#define PPP_THREAD_STACKSIZE            0
//#define PPP_THREAD_PRIO                 1
//#define DEFAULT_THREAD_NAME            "lwIP"
//#define DEFAULT_THREAD_STACKSIZE        0
//#define DEFAULT_THREAD_PRIO             1
//#define DEFAULT_RAW_RECVMBOX_SIZE       0
//#define DEFAULT_UDP_RECVMBOX_SIZE       0
//#define DEFAULT_TCP_RECVMBOX_SIZE       0
//#define DEFAULT_ACCEPTMBOX_SIZE         0

//*****************************************************************************
//
// ---------- Sequential layer options ----------
//
//*****************************************************************************
//#define LWIP_TCPIP_CORE_LOCKING         0
#define LWIP_NETCONN                    0          // default is 1

//*****************************************************************************
//
// ---------- Socket Options ----------
//
//*****************************************************************************
#define LWIP_SOCKET                     0           // default is 1
//#define LWIP_COMPAT_SOCKETS             1
//#define LWIP_POSIX_SOCKETS_IO_NAMES     1
//#define LWIP_TCP_KEEPALIVE              0
//#define LWIP_SO_RCVTIMEO                0
//#define LWIP_SO_RCVBUF                  0
//#define SO_REUSE                        0

//*****************************************************************************
//
// ---------- Statistics options ----------
//
//*****************************************************************************
//#define LWIP_STATS                      1
//#define LWIP_STATS_DISPLAY              1//0
//#define LINK_STATS                      1
//#define ETHARP_STATS                    (LWIP_ARP)
//#define IP_STATS                        1
//#define IPFRAG_STATS                    (IP_REASSEMBLY || IP_FRAG)
//#define ICMP_STATS                      1
//#define IGMP_STATS                      (LWIP_IGMP)
//#define UDP_STATS                       (LWIP_UDP)
//#define TCP_STATS                       (LWIP_TCP)
//#define MEM_STATS                       1
//#define MEMP_STATS                      1
//#define SYS_STATS                       1

//*****************************************************************************
//
// ---------- PPP options ----------
//
//*****************************************************************************
//#define PPP_SUPPORT                     0
//#define PPPOE_SUPPORT                   0
//#define PPPOS_SUPPORT                   PPP_SUPPORT

#if PPP_SUPPORT
//#define NUM_PPP                         1
//#define PAP_SUPPORT                     0
//#define CHAP_SUPPORT                    0
//#define MSCHAP_SUPPORT                  0
//#define CBCP_SUPPORT                    0
//#define CCP_SUPPORT                     0
//#define VJ_SUPPORT                      0
//#define MD5_SUPPORT                     0
//#define FSM_DEFTIMEOUT                  6
//#define FSM_DEFMAXTERMREQS              2
//#define FSM_DEFMAXCONFREQS              10
//#define FSM_DEFMAXNAKLOOPS              5
//#define UPAP_DEFTIMEOUT                 6
//#define UPAP_DEFREQTIME                 30
//#define CHAP_DEFTIMEOUT                 6
//#define CHAP_DEFTRANSMITS               10
//#define LCP_ECHOINTERVAL                0
//#define LCP_MAXECHOFAILS                3
//#define PPP_MAXIDLEFLAG                 100

//#define PPP_MAXMTU                      1500
//#define PPP_DEFMRU                      296
#endif

//*****************************************************************************
//
// ---------- checksum options ----------
//
//*****************************************************************************
#define CHECKSUM_GEN_IP                 0
#define CHECKSUM_GEN_ICMP               0
#define CHECKSUM_GEN_UDP                0
#define CHECKSUM_GEN_TCP                0
#define CHECKSUM_CHECK_IP               0
#define CHECKSUM_CHECK_UDP              0
#define CHECKSUM_CHECK_TCP              0

//*****************************************************************************
//
// ---------- Debugging options ----------
//
//*****************************************************************************
#if 1//def DEBUG
#define U8_F "c"
#define S8_F "c"
#define X8_F "02x"
#define U16_F "u"
#define S16_F "d"
#define X16_F "x"
#define U32_F "u"
#define S32_F "d"
#define X32_F "x"
extern void UARTprintf(const char *pcString, ...);
#define LWIP_PLATFORM_DIAG(msg) UARTprintf msg
#define LWIP_PLATFORM_ASSERT(msg)                                             \
    UARTprintf("ASSERT FAIL at line %d of %s: %s\n", __LINE__, __FILE__, msg)
#define LWIP_DEBUG 1
#endif

//#define LWIP_DBG_MIN_LEVEL              LWIP_DBG_LEVEL_OFF
//#define LWIP_DBG_MIN_LEVEL              LWIP_DBG_LEVEL_OFF
//#define LWIP_DBG_MIN_LEVEL              LWIP_DBG_LEVEL_WARNING
#define LWIP_DBG_MIN_LEVEL              LWIP_DBG_LEVEL_SERIOUS
//#define LWIP_DBG_MIN_LEVEL              LWIP_DBG_LEVEL_SEVERE

//#define LWIP_DBG_TYPES_ON               LWIP_DBG_ON
//#define LWIP_DBG_TYPES_ON               (LWIP_DBG_ON|LWIP_DBG_TRACE|        \
                                           LWIP_DBG_STATE|LWIP_DBG_FRESH)

//#define ETHARP_DEBUG                    LWIP_DBG_ON     // default is OFF
#define NETIF_DEBUG                     LWIP_DBG_OFF
//#define PBUF_DEBUG                      LWIP_DBG_OFF
//#define API_LIB_DEBUG                   LWIP_DBG_OFF
//#define API_MSG_DEBUG                   LWIP_DBG_OFF
//#define SOCKETS_DEBUG                   LWIP_DBG_OFF
#define HTTPD_DEBUG                     LWIP_DBG_OFF
//#define ICMP_DEBUG                      LWIP_DBG_OFF
//#define IGMP_DEBUG                      LWIP_DBG_OFF
//#define INET_DEBUG                      LWIP_DBG_OFF
//#define IP_DEBUG                        LWIP_DBG_ON
//#define IP_REASS_DEBUG                  LWIP_DBG_OFF
#define RAW_DEBUG                       LWIP_DBG_OFF
#define MEM_DEBUG                       LWIP_DBG_ON
//#define MEMP_DEBUG                      LWIP_DBG_OFF
//#define SYS_DEBUG                       LWIP_DBG_OFF
//#define TCP_DEBUG                       LWIP_DBG_ON
#define TCP_INPUT_DEBUG                 LWIP_DBG_ON
//#define TCP_FR_DEBUG                    LWIP_DBG_OFF
//#define TCP_RTO_DEBUG                   LWIP_DBG_OFF
//#define TCP_CWND_DEBUG                  LWIP_DBG_OFF
//#define TCP_WND_DEBUG                   LWIP_DBG_OFF
#define TCP_OUTPUT_DEBUG                LWIP_DBG_ON
//#define TCP_RST_DEBUG                   LWIP_DBG_OFF
//#define TCP_QLEN_DEBUG                  LWIP_DBG_OFF
//#define UDP_DEBUG                       LWIP_DBG_ON     // default is OFF
//#define TCPIP_DEBUG                     LWIP_DBG_ON
//#define PPP_DEBUG                       LWIP_DBG_OFF
//#define SLIP_DEBUG                      LWIP_DBG_OFF
//#define DHCP_DEBUG                      LWIP_DBG_ON     // default is OFF
//#define AUTOIP_DEBUG                    LWIP_DBG_OFF
//#define SNMP_MSG_DEBUG                  LWIP_DBG_OFF
//#define SNMP_MIB_DEBUG                  LWIP_DBG_OFF
//#define DNS_DEBUG                       LWIP_DBG_OFF


// Error Defines
#define LWIP_PROVIDE_ERRNO 			1
#define LWIP_COMPAT_MUTEX_ALLOWED 	1

// Ethernet Interface Functionality Enable Defines
#define HTTP_ENABLE_PASSWORD 			1
#define HTTP_ENABLE_SESSION_TIMEOUT 	1

#endif /* __LWIPOPTS_H__ */

How I could fixed this problem?

Thanks

  • Hi Leonan,

    I wonder if you need to create a handler on the lwip side for a SSI tag you created in the html? I need to assign your post to our SME for further assist.

    coherentmusings.wordpress.com/.../
  • Hi Charles,

    I configured the ssi tag handler on the LWIP. This works perfectly.


    The error is in the server. It stops working completely, even when I disabled the ssi tags.

    When the error ocurrs, the system go to Fault ISR, but sometimes only the server stop, and the other tasks in the FreeRTOS works.

    I believe it's memory error in the LWIP. I use the 2.0.0 version

    Thanks
  • Hello Leonan,

    Please refer the "freertos_demo" in the folder "./examples/boards/dk-tm4c129x". It uses lwIP and HTTP Server running on FreeRTOS.

    Since that example was created for the DK-TM4C129X board it won't work out of box on the EK-TM4C1294XL board, but is a good project to reference for using lwIP with FreeRTOS.

    Thanks,
    Sai
  • Hello, Sai

    I work with Leonan. We do not have any problems setting up the SSI tags of making lwIP work with FreeRTOS.

    The HTTP Server, SSI tags and the CGI handlers are working perfectly. The only problem is that, if the application is left running for some time, it enters in FaultISR.If we set the webpage to refresh every 'x' seconds, the time for the code to give us a FaultISR is severely reduced (from some hours to ~5 to 10 minutes). However, if we disable the refresh, the FaultISR still happens after a longer time.

    Our application uses FreeRTOS to schedule different tasks. If we disable the task responsible for the lwIP, the FaultISR does not happen, even if executing non-stop for a week (we tested that). This makes us believe the problem must be with lwIP executing for "too long".

    We also tested on another example from Tivaware (enet_io), modifying it to refresh the webpage every 1 second but leaving the rest intact. We got the same behavior, so I don't think the problem is caused by some particularity of our code.

    We wonder if this problem is not caused by a memory leak in the library. We have seen some topics in the forum speaking about similar problems related to this:

    https://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/p/450416/1626644

    https://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/t/417592?tisearch=e2e-quicksearch&keymatch=lwip%20memory%20leak

    Unfortunately, none of them could solve our problem.

    How can we confirm or deny our suspicion?

  • I've tried the same tag on enet_io here and the same problem happened to me. 

    It seems the memory leak on TM4C devices was not solved on latest versions of Tivaware.

    That is a very big issue since the phy free Ethernet connection is the selling point for TM4C129x devices.

    I sincerely hope Texas engineers manage to solve the issue 

  • Hello Sai,

    I created my project based on the freertos_demo example, with the necessary modifications for it to be compatible with the TM4C1294ncpdt device.

    We tested the LWIP without FreeRTOS, based on enet_io example, but the problem persists.


    When I try to increase the heap size of this project, the time between failure increases too. Now it takes around 20 minutes.

    We believe if this problem occurs because of a memory leak inside LWIP on the TM4C devices.



    That is a critical issue, was not solved on the latest versions of the Tivaware.

    I hope Texas engineers solve that.

    Thanks.

  • I finally solved this problem!

    Reading the lwip wiki (lwip.wikia.com/.../Tuning_TCP), I find how to configure the parameters oh the TCP protocol.

    The macro TCP_MSS is the maximum segment size controls the maximum amount of payload bytes per packet.

    TCP_WND is set to at least 2xTCP_MSS and TCP_SND_BUF is equal to TCP_WND (for maximum throughput).

    I modify the lwipopts.h to:

    //*****************************************************************************
    //
    // ---------- TCP options ----------
    //
    //*****************************************************************************
    #define LWIP_TCP                        1
    //#define TCP_TTL                         (IP_DEFAULT_TTL)
    #define TCP_WND                        256 // default is 2048
    //#define TCP_MAXRTX                      12
    //#define TCP_SYNMAXRTX                   6
    //#define TCP_QUEUE_OOSEQ                 1
    #define TCP_MSS                        128 // default is 128
    //#define TCP_CALCULATE_EFF_SEND_MSS      1
    #define TCP_SND_BUF                     TCP_WND // default is (4 * TCP_MSS)
    //#define TCP_SND_QUEUELEN                (4 * (TCP_SND_BUF/TCP_MSS))
    //#define TCP_SNDLOWAT                    (TCP_SND_BUF/2)
    //#define TCP_LISTEN_BACKLOG              0
    //#define TCP_DEFAULT_LISTEN_BACKLOG      0xff

    I modified too the priority of TCPIP thread to 1 and the stacksize of this thread.

    //*****************************************************************************
    //
    // ---------- Thread options ----------
    //
    //*****************************************************************************
    #define TCPIP_THREAD_NAME              "tcpip"
    #define TCPIP_THREAD_STACKSIZE          4096// was 2048
    #define TCPIP_THREAD_PRIO               1// was 14
    #define TCPIP_MBOX_SIZE                 32


  • This topic should be pinned. The default values on Tivaware examples are very much different from these ones and it's very hard to debug a system with problems exactly there.
  • There are some other important details to address related to this problem.

    In the file httpd.c, which implements the LwIP's HTTP server, you can find the following lines:

    #define HTTP_ALLOC_HTTP_STATE() (struct http_state *)mem_malloc(sizeof(struct http_ssi_state))
    #define HTTP_FREE_HTTP_STATE(x) mem_free(x)
    #if LWIP_HTTPD_SSI
    #define HTTP_ALLOC_SSI_STATE()  (struct http_ssi_state *)mem_malloc(sizeof(struct http_ssi_state))
    #define HTTP_FREE_SSI_STATE(x)  mem_free(x)​

    However, the methods mem_malloc and mem_free, standard memory management methods for LwIP, are NOT thread safe.
    It would be wise to change them for their FreeRTOS thread safe counterparts: pvPortMalloc and vPortFree.

    The resulting code would be something like this:

    #define HTTP_ALLOC_HTTP_STATE() (struct http_state *)pvPortMalloc(sizeof(struct http_ssi_state))
    #define HTTP_FREE_HTTP_STATE(x) vPortFree(x)
    #if LWIP_HTTPD_SSI
    #define HTTP_ALLOC_SSI_STATE()  (struct http_ssi_state *)pvPortMalloc(sizeof(struct http_ssi_state))
    #define HTTP_FREE_SSI_STATE(x)  vPortFree(x)​​

     


    Also, pay attention to what memory management implementation of FreeRTOS you are using. According to their online documentation ( http://www.freertos.org/a00111.html ) there are 5 different implementations included in the RTOS source code. You can see which one you are using inside the
    Source/Portable/MemMang folder. Note that only one of the "heap_x.c" files may be present inside this folder at a time.

    If you are using implementation number 1 (heap_1), you do not allow previously allocated memory to be freed, and this can be causing the memory leak.

    When I tested with implementation number 4 (heap_4) the problem appeared to be solved.