virtmem
virtual memory library for Arduino
virtmem::DefaultAllocProperties Struct Reference

This struct contains default parameters for virtual memory pages. More...

#include <config.h>

Static Public Attributes

static const uint8_t smallPageCount
 The number of small pages.
 
static const uint8_t smallPageSize
 The size of a small page.
 
static const uint8_t mediumPageCount
 The number of medium pages.
 
static const uint8_t mediumPageSize
 The size of a medium page.
 
static const uint8_t bigPageCount
 The number of big pages.
 
static const uint8_t bigPageSize
 The size of a big page.
 

Detailed Description

This struct contains default parameters for virtual memory pages.

The fields in this struct define the amount- and size of the small, medium and big memory pages for an allocator. The former two memory pages are only used for locking data. In general it is best to make sure that they are big enough to contain any structs/classes stored in virtual memory. The big memory pages are also used for data locking, but more importantly, they are used as a cache for virtual memory access (see basics).

Since all memory pages reside in regular RAM, changing their size and amount greatly influences the RAM used by virtmem. Besides reducing the RAM usage by lowering the amount and/or size of memory pages, it is also interesting to increase these numbers if you have some spare RAM. In general, increasing the number of pages will enhance random access times, whereas increasing the size of memory pages will reduce costly swapping and improve sequential memory access.

The default size and amount of memory pages is platform dependent, and can be changed in config.h. Alternatively, page settings can be set by defining a customized structure and passing this structure as a template parameter to an allocator.

Example:

// This struct contains a customized set of memory page properties.
// While the datatype of each member does not matter, all members must be static.
struct AllocProperties
{
static const uint8_t smallPageCount = 4, smallPageSize = 64;
static const uint8_t mediumPageCount = 4, mediumPageSize = 128;
static const uint8_t bigPageCount = 4,
static const uint16_t bigPageSize = 512; // note: uint16_t to contain larger numeric value
};
// Create allocator with customized page properties
SDVAllocP<AllocProperties> alloc;
See also
alloc_properties.ino example

The documentation for this struct was generated from the following file: