Skip to content

Commit 2092095

Browse files
Alexander KozhinovAlexander Kozhinov
Alexander Kozhinov
authored and
Alexander Kozhinov
committed
samples: net: civetweb: reduce RAM usage
adjust configuration so that civetweb uses less memory fixes #21179 Signed-off-by: Alexander Kozhinov <[email protected]>
1 parent cd68e58 commit 2092095

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

samples/net/sockets/civetweb/prj.conf

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ CONFIG_NET_IPV4=y
1313
# CONFIG_NET_IPV6 is not set
1414
CONFIG_NET_TCP=y
1515
CONFIG_NET_SOCKETS=y
16-
CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=131072
17-
CONFIG_NET_TX_STACK_SIZE=8192
18-
CONFIG_NET_RX_STACK_SIZE=8192
19-
CONFIG_ISR_STACK_SIZE=8192
20-
CONFIG_MAIN_STACK_SIZE=8192
21-
CONFIG_IDLE_STACK_SIZE=2048
16+
CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=16384
17+
CONFIG_NET_TX_STACK_SIZE=2048
18+
CONFIG_NET_RX_STACK_SIZE=2048
19+
CONFIG_ISR_STACK_SIZE=2048
20+
CONFIG_MAIN_STACK_SIZE=2048
21+
CONFIG_IDLE_STACK_SIZE=1024
2222

2323
CONFIG_DNS_RESOLVER=y
2424

samples/net/sockets/civetweb/src/main.c

+10-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@
1010

1111
#include "civetweb.h"
1212

13-
#define CIVETWEB_MAIN_THREAD_STACK_SIZE 4096
13+
#define HTTP_PORT 8080
14+
#define HTTPS_PORT 4443
15+
16+
#define CIVETWEB_MAIN_THREAD_STACK_SIZE CONFIG_MAIN_STACK_SIZE
17+
18+
/* Use samllest possible value of 1024 (see the line 18619 of civetweb.c) */
19+
#define MAX_REQUEST_SIZE_BYTES 1024
1420

1521
K_THREAD_STACK_DEFINE(civetweb_stack, CIVETWEB_MAIN_THREAD_STACK_SIZE);
1622

@@ -139,12 +145,12 @@ void *main_pthread(void *arg)
139145
{
140146
static const char * const options[] = {
141147
"listening_ports",
142-
"8080",
148+
STRINGIFY(HTTP_PORT),
143149
"num_threads",
144150
"1",
145151
"max_request_size",
146-
"2048",
147-
0
152+
STRINGIFY(MAX_REQUEST_SIZE_BYTES),
153+
NULL
148154
};
149155

150156
struct mg_callbacks callbacks;

0 commit comments

Comments
 (0)