MoonGen
|
Memory ... More...
Go to the source code of this file.
Functions | |
function mod | alloc (ctype, size) |
Off-heap allocation, not garbage-collected. More... | |
function mod | free (buf) |
Free off-heap allocated object. | |
function mod | allocHuge (ctype, size) |
Off-heap allocation on huge pages, not garbage-collected. More... | |
function mod | enableCache () |
Enable mempool recycling. More... | |
param n | optional (default=2047) |
Create a new memory pool. More... | |
function mod | createMemPool (...) |
function mod | freeMemPools () |
Free all memory pools owned by this task. More... | |
function mempool | retain () |
Retain a memory pool. More... | |
function mempool | bufArray (n) |
Create a new array of memory buffers (initialized to nil). | |
function bufArray | offloadIPChecksums (ipv4, l2Len, l3Len, n) |
If called, IP chksum offloading will be done for the first n packets. | |
function bufArray | setVlans (vlan, pcp, cfi) |
Offloads VLAN tags on all packets. | |
function bufArray | alloc (size) |
Allocates buffers from the memory pool and fills the array. | |
function bufArray | freeAll () |
Free all buffers in the array. Stops when it encounters the first one that is null. | |
function bufArray | free (n) |
Free the first n buffers. | |
Variables | |
n = self | |
Create a new array of memory buffers (initialized to nil). | |
function mod alloc | ( | ctype | , |
size | |||
) |
Off-heap allocation, not garbage-collected.
ctype | a ffi type, must be a pointer or array type |
size | the amount of memory to allocate |
function mod allocHuge | ( | ctype | , |
size | |||
) |
Off-heap allocation on huge pages, not garbage-collected.
See memory.alloc. TODO: add a free function for this
function mod createMemPool | ( | ... | ) |
socket | optional (default = socket of the calling thread), NUMA association. This cannot be the only argument in the call. |
bufSize | optional the size of each buffer, can only be used if all other args are passed as well |
function mod enableCache | ( | ) |
Enable mempool recycling.
Calling this function enables the mempool cache. This prevents memory leaks as DPDK cannot delete mempools. Mempools with the same parameters created on the same core will be recycled. This is not yet enabled by default because I'm not 100% confident that it works properly in all cases. For example, mempools passed to other tasks will probably break stuff.
function mod freeMemPools | ( | ) |
Free all memory pools owned by this task.
All queues using these pools must be stopped before calling this.
param n optional | ( | default | = 2047 | ) |
Create a new memory pool.
Memory pools are recycled once the owning task terminates. Call :retain() for mempools that are passed to other tasks. A table with named arguments should be used.
args | A table containing the following named arguments |
function mempool retain | ( | ) |
Retain a memory pool.
This will prevent the pool from being returned to a pool of pools once the task ends.