K60 webserver ram usage

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

K60 webserver ram usage

629 Views
leepenn
Contributor III


I am having issues with the webserver and ram usage on the K60 with MQX 4.0.2.2 . My other tasks are using 54k of my ram and I am using the minimum footprint settings. When I enable the webserver it increases the size to 85k, until I serve up a web page then it sometimes increases to max size and can randomly not show parts of the webpage. I tried using the new HTTPSRV_init(&params); command but was running into memory issues when it created the tasks, so I rolled back to using httpd_server_init_af. I have tried decreasing stack size of the webserver_task as it shows it is using only 29% but that causes the tcp/ip task to get an out of memory error. I have also noted that the other task httpd_server task is also using under 50 percent but any changes I make also cause out of memory or out of blocks errors.

I am wondering if there is anyway other way to limit the ram usage of the webserver without causing intermittent web page displays?

Labels (1)
0 Kudos
1 Reply

222 Views
Carlos_Musich
NXP Employee
NXP Employee

1) It seems that your tasks are allocating a huge stack and there is not enough memory for the server. With TAD (Task Awae Debugger) you can see the your task usage, try reducing your tasks stack size to have 90% of usage in each task.You can find information about how to use TAD  in MQX Quick Start Guide located in documentation folder in MQX installation path.

2) If the problem persists you may not have enough stack for the server. When you call the function HTTPSRV_init() it uses the structure HTTPSRV_PARAM_STRUCT to be initialized, in this structure you have the "script_stack" variable which is the size of the stack of the script handler task in bytes. Try to set the value of this variable according to the memory requirements of your CGI callbacks. The default value is 750 bytes. I strongly recommend to use this server which is the new MQX4.0 server.

3) If you are running out of blocks it might be possible that you need more PCBs, MSG and sockets. Could you please add the next lines just before call the function RTCS_create() just as the web_hvac does in the C:\Freescale\Freescale MQX 4.0\demo\web_hvac\RTCS.c file?

/* runtime RTCS configuration */
_RTCSPCB_init = 4;
_RTCSPCB_grow = 2;
_RTCSPCB_max = 20;
_RTCS_msgpool_init = 4;
_RTCS_msgpool_grow = 2;
_RTCS_msgpool_max = 20;
_RTCS_socket_part_init = 4;
_RTCS_socket_part_grow = 2;
_RTCS_socket_part_max = 20;

4) You can also modify your sockets bffers size. With TAD you can also check TCP socket connection memory usage.You can call setsockopt() to reduce OPT_TBSIZE and OPT_RBSIZE and the memory usage to open a new TCP socket will be reduced. E.g.

uint_32 value;

value = 1024;
setsockopt(sock, SOL_TCP,OPT_TBSIZE,&value,sizeof(value));
setsockopt(sock, SOL_TCP,OPT_RBSIZE,&value,sizeof(value));


5) Finally, if you dont have all MQX4.0.2 patches you may be missing some MQX fixes. Please take a look to the link below.
https://community.freescale.com/message/351405#351405


I hope this helps. Have a nice day!

Carlos

0 Kudos