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 Number||Name||RAM||CPU Speed|
|AMW004||Wallaby||128 kB||120 MHz|
|AMW006||Numbat||96 kB||80 MHz|
For a more detailed module comparison, see Module Comparison.
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:
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
heap_size = total_memory_size - reserved_size - network.buffer.size
- Adjusting network.buffer.size alters the total heap size available.
- Adjusting network.buffer.rxtx_ratio changes the proportion of the network buffer available for Rx and Tx. It does not change network buffer size.
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:
- NTP client - see NTP variables
- Broadcast of properties - see Broadcast variables
- RSSI averaging - see wlan.rssi_average
- Network buffer size set above minimum value - see network.buffer.size
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:
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.
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).
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.
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.