Memory Leak problem in LPC1788 with FreeRTOS 7.10 and LWIP1.41

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Memory Leak problem in LPC1788 with FreeRTOS 7.10 and LWIP1.41

388 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mstsai on Thu Nov 15 22:40:43 MST 2012
Dear All:

I have been working on the LPC1788 with FreeRTOS and LWIP in the past few weeks.  The system has 32MB of SDRAM.  So, I reserved 4MB to the LWIP.   Originally, I developed a TFTP client to send data to a remote server every few minutes.  The data size is about 150KB.  However, the system stopped sending packets to the server after few hours.  In order to identify the problem, I create a project with only one task, SNTP, in FreeRTOS.  I have set up the SNTP to acquire the time information from NTP server every 10 seconds.  The heap memory statistics is printed after each access to see how the heap is used.  I have discovered that for every NTP access, the used heap increases slightly, about 150 bytes.  The number keeps increasing.  The outputs are shown below.

If this is a type of memory leak problem, how do I identify the source of the leak and fix the problem?

Any suggestion would be appreciated.



MEM HEAP
        avail: 4194304
        used: 218144
        max: 219708
        err: 0
sntp_send_request: Sending request to server
2012/11/16-13:35:25
sntp_process: Fri Nov 16 05:35:25 2012
sntp_recv: Scheduled next time request: 10000 ms
....******* RTC IRQ Handler : 13:35:30 ********
.....
MEM HEAP
        avail: 4194304
        used: 218276
        max: 219840
        err: 0
sntp_send_request: Sending request to server
2012/11/16-13:35:35
sntp_process: Fri Nov 16 05:35:35 2012
sntp_recv: Scheduled next time request: 10000 ms
....******* RTC IRQ Handler : 13:35:40 ********
.....
MEM HEAP
        avail: 4194304
        used: 218408
        max: 219972
        err: 0
sntp_send_request: Sending request to server
2012/11/16-13:35:45
sntp_process: Fri Nov 16 05:35:45 2012
sntp_recv: Scheduled next time request: 10000 ms
....******* RTC IRQ Handler : 13:35:50 ********
.....
MEM HEAP
        avail: 4194304
        used: 218540
        max: 220104
        err: 0
sntp_send_request: Sending request to server
2012/11/16-13:35:56
sntp_process: Fri Nov 16 05:35:56 2012
sntp_recv: Scheduled next time request: 10000 ms
...
Labels (1)
0 Kudos
2 Replies

315 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by nagaraj.baddi on Thu Oct 31 00:27:41 MST 2013
Hi mstsai,

I am new to TFTP server/client, I could please share the working sample example, it help my project.

Thanks & Regards
Nagaraj Baddi
0 Kudos

315 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mstsai on Wed Nov 21 17:46:44 MST 2012
Hmmmm.. 

Dont know if anyone ran into the same situation.  I developed a TFTP client that uploads a file to a TFTP server.  The size of the file is about 250KB.  I also turned on MEMP_MEM_MALLOC and MEM_LIBC_MALLOC instead of internal pool.
The debug messages showed that some memories were not released.  Memory fragmentation is expected.  For each transaction, few blocks were lost.



14571308 bytes in 875 free blocks (avge size 16652)
36 blocks 2^2+1 to 2^3
715 blocks 2^3+1 to 2^4
112 blocks 2^4+1 to 2^5
3 blocks 2^5+1 to 2^6
1 blocks 2^6+1 to 2^7
2 blocks 2^7+1 to 2^8
5 blocks 2^9+1 to 2^10
1 blocks 2^22+1 to 2^23

Transferring 20121122-084040.pqd to TFTP server(192.168.0.132), port 69
TFTP done!
14540716 bytes in 892 free blocks (avge size 16301)
36 blocks 2^2+1 to 2^3
730 blocks 2^3+1 to 2^4
113 blocks 2^4+1 to 2^5
2 blocks 2^5+1 to 2^6
1 blocks 2^6+1 to 2^7
2 blocks 2^7+1 to 2^8
3 blocks 2^8+1 to 2^9
4 blocks 2^9+1 to 2^10

1 blocks 2^22+1 to 2^23
Transferring 20121122-084100.pqd to TFTP server(192.168.0.132), port 69
TFTP done!
14510124 bytes in 905 free blocks (avge size 16033)
37 blocks 2^2+1 to 2^3
745 blocks 2^3+1 to 2^4
114 blocks 2^4+1 to 2^5
2 blocks 2^5+1 to 2^6
2 blocks 2^6+1 to 2^7
1 blocks 2^7+1 to 2^8
3 blocks 2^9+1 to 2^10
1 blocks 2^22+1 to 2^23

sntp_send_request: Sending request to server
2012/11/22-08:41:21
sntp_process: Thu Nov 22 08:41:21 2012
sntp_recv: Scheduled next time request: 60000 ms


0 Kudos