Memory

WiConnect requires memory (RAM) as working space to hold intermediate calculations and to buffer serial and network data. The amount of memory available in a module impacts the number of features that can be run concurrently, as well as the maximum throughput that is achieveable. Modules with more RAM support more features and achieve higher throughput. ACKme offers modules with differing amounts of RAM as shown in the follow table.

Part NumberNameRAMCPU Speed
AMW004Wallaby128 kB120 MHz
AMW006Numbat96 kB80 MHz
AMW106Numbat 106128 kB100 MHz

For a more detailed module comparison, see Module Comparison.

Memory Management

WiConnect features require varying amounts of RAM. Features like the HTTP Server, TLS server and goHACK.me solo mode are memory intensive. In some cases it may not be possible to run memory intensive features simultaneously.

For example, it is not possible to run simultaneously two TLS sessions, or two HTTPS sessions. On a Numbat module, it is not possible to run the HTTP server and simultaneously activate the module for goHACK.me.

Some websites use large TLS certificate chains that may exceed the RAM capacity of the module resulting in a failed connection.

When memory usage is greater than 90%, the system displays a warning every 30 seconds: WARN: Low memory, system may become unstable

Determining Memory Usage

Applications use heap memory. To see the percentage of available heap currently allocated, use the system.memory_usage variable: get system.memory_usage

The diagram below shows a high level map of module memory allocation.

The percentage memory usage returned by system.memory_usage is calculated as follows:

system.memory_usage = 100*heap_used/heap_size

where

heap_size = total_memory_size - reserved_size - network.buffer.size

Notes:

Minimizing Memory Usage

To minimize memory usage, disable services that are not in use and set default memory allocations to the minimum.

Default features that consume memory include:

Of these features, network buffer size has the most impact on memory usage. Setting network buffer size to the maximum can consume 30% or more of available heap. NTP client, broadcast and RSSI averaging each consume less than 1% of available heap.

However, the module needs around 20K of network buffer for normal operation.

To minimize memory usage, disable defaults using the following WiConnect commands:

WiConnect commandsDescription

set ntp.enabled 0
set broadcast.interval 0
set wlan.rssi_average 0
set network.buffer.size 20000
save
reboot

Disable the NTP client
Turn off UDP and HTTP broadcast
Disable RSSI averaging
Minimize the network buffer size



Streams

Applications that use streams consume memory according to the number of streams in use. Streams are used by the file system, and the various servers and clients. For usage and limits on streams, see Network Connections and Streams.

Memory Management Variables

Some variables allow control of the size and proportion of memory allocated to various tasks.

HTTP clients

It may be necessary to restrict the maximum number of clients the HTTP server allows. Since each HTTP client uses a stream, restricting clients prevents excessive memory usage, and it also avoids web browsers opening multiple streams for a single connection (some browsers do this in an effort to minimize page load time).

Network Buffer

Reducing the network buffer size may prevent excessive memory usage. In some applications that are either receive or transmit intensive, efficiency can be improved by adjusting the ratio of Rx and Tx buffer usage. Monitor network buffer usage with the network.buffer.usage variable.

goHACK.me Cache

When using goHACK.me in solo mode, samples are cached before sending to the goHACK.me server. You can adjust the size of the cache to manage memory.