Memory Configuration
µC/HTTP-server can use a dedicated memory segment to allocate its internal objects (OS semaphore, OS mutex, buffers, control structures, etc.) or use the µC/LIB Heap memory. The first argument of function HTTPs_Init is the pointer to the memory segment to use for HTTP server. If the argument is set to NULL, the Heap memory from µC/LIB will be used for memory allocation by the HTTP server.
Since µC/HTTP-server is using dynamic memory pools for most of its internal objects (Instance structure objects, connection structure objects,etc.), the server is initialized with the minimum setting and therefore, the pools' size can grow during the application run time. The instance initialization will failed if the minimum settings is to big for the memory space available.
The maximum memory size required by the µC/HTTP-server depends on many factors and therefore it's impossible to provide an exact formula to calculate it. It's depends, amongst others, on the application module configuration (in http-s_cfg.h) and each instance configuration (HTTPs_CFG
object) but also on the growing of the different internal dynamic pools used by the HTTP server. To insure that enough space is available, we recommend exercising your application at the limit you intend to support, i.e., Set all the instances, use the maximum number of connection simultaneously with all the features you are intended to use at their maximum capacity (e.g. Add the maximum number of headers configured to the HTTP response). If the application returns a memory error during the run time or if any memory error counters have been incremented, your memory size is not enough big for your application configuration. Therefore, you will need to increase your memory space (the µC/LIB heap size or your memory segment size) or adjust your HTTP server configuration downwards. If your application is running correctly even when stressed at its limit, you can look at the memory space remaining (see function Mem_SegRemSizeGet()) to adjust your memory size.
Also, the Instance task's stack will be allocated according to the parameter StkPtr
of the NET_TASK_CFG
object passed in the function HTTPs_InstanceInit. If the parameter is set to NULL, the stack will be allocated on the Heap memory of µC/LIB, else it will be allocated at the memory segment referred to by the StkPtr
parameter. Therefore, if the Heap memory is used, the stack size of each HTTP server Instance must be considered when setting the Heap size.
Note: The memory module must be initialized by the application prior to calling HTTPs_Init()
. We recommend initializing the memory module before calling starting the RTOS, or near the top of the startup task.
Please refer to section µC/LIB Documentation for more details on the µC/LIB module and its configuration.