<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.16"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <title>UbixOS V2: Heap and memory pools</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="navtree.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="resize.js"></script> <script type="text/javascript" src="navtreedata.js"></script> <script type="text/javascript" src="navtree.js"></script> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ $(document).ready(initResizable); /* @license-end */</script> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="search/searchdata.js"></script> <script type="text/javascript" src="search/search.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td id="projectalign" style="padding-left: 0.5em;"> <div id="projectname">UbixOS V2  <span id="projectnumber">2.0</span> </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.16 --> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ var searchBox = new SearchBox("searchBox", "search",false,'Search'); /* @license-end */ </script> <script type="text/javascript" src="menudata.js"></script> <script type="text/javascript" src="menu.js"></script> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ $(function() { initMenu('',true,false,'search.php','Search'); $(document).ready(function() { init_search(); }); }); /* @license-end */</script> <div id="main-nav"></div> </div><!-- top --> <div id="side-nav" class="ui-resizable side-nav-resizable"> <div id="nav-tree"> <div id="nav-tree-contents"> <div id="nav-sync" class="sync"></div> </div> </div> <div id="splitbar" style="-moz-user-select:none;" class="ui-resizable-handle"> </div> </div> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ $(document).ready(function(){initNavTree('group__lwip__opts__mem.html','');}); /* @license-end */ </script> <div id="doc-content"> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> </div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <div class="header"> <div class="summary"> <a href="#define-members">Macros</a> </div> <div class="headertitle"> <div class="title">Heap and memory pools<div class="ingroups"><a class="el" href="group__lwip__opts.html">Options (lwipopts.h)</a> » <a class="el" href="group__lwip__opts__infrastructure.html">Infrastructure</a></div></div> </div> </div><!--header--> <div class="contents"> <div class="dynheader"> Collaboration diagram for Heap and memory pools:</div> <div class="dyncontent"> <div class="center"><img src="group__lwip__opts__mem.png" border="0" usemap="#group____lwip____opts____mem" alt=""/></div> </div> <table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a> Macros</h2></td></tr> <tr class="memitem:ga0a3ef6098813c103e5aba07da76e15e2"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__lwip__opts__mem.html#ga0a3ef6098813c103e5aba07da76e15e2">LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT</a>   0</td></tr> <tr class="separator:ga0a3ef6098813c103e5aba07da76e15e2"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ga97343214666ee6dcb18c0bd77b441ea7"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__lwip__opts__mem.html#ga97343214666ee6dcb18c0bd77b441ea7">MEM_ALIGNMENT</a>   1</td></tr> <tr class="separator:ga97343214666ee6dcb18c0bd77b441ea7"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ga4ef345cc270912bd2230b1c5ec51dfc8"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__lwip__opts__mem.html#ga4ef345cc270912bd2230b1c5ec51dfc8">MEM_LIBC_MALLOC</a>   0</td></tr> <tr class="separator:ga4ef345cc270912bd2230b1c5ec51dfc8"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ga2dcf8c45f945dd0c4301a94700f2112c"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__lwip__opts__mem.html#ga2dcf8c45f945dd0c4301a94700f2112c">MEM_SIZE</a>   1600</td></tr> <tr class="separator:ga2dcf8c45f945dd0c4301a94700f2112c"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:gaddca3141bc7037241769eb152b6f89ba"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__lwip__opts__mem.html#gaddca3141bc7037241769eb152b6f89ba">MEM_USE_POOLS</a>   0</td></tr> <tr class="separator:gaddca3141bc7037241769eb152b6f89ba"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:gaba8be68e8fd0716b723ce4569ed89f82"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__lwip__opts__mem.html#gaba8be68e8fd0716b723ce4569ed89f82">MEM_USE_POOLS_TRY_BIGGER_POOL</a>   0</td></tr> <tr class="separator:gaba8be68e8fd0716b723ce4569ed89f82"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:gae93af697d27bbcefa6a28052d90f2f38"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__lwip__opts__mem.html#gae93af697d27bbcefa6a28052d90f2f38">MEMP_MEM_MALLOC</a>   0</td></tr> <tr class="separator:gae93af697d27bbcefa6a28052d90f2f38"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ga27fdd01194a42fc41a7716b72cdb49e3"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__lwip__opts__mem.html#ga27fdd01194a42fc41a7716b72cdb49e3">MEMP_OVERFLOW_CHECK</a>   0</td></tr> <tr class="separator:ga27fdd01194a42fc41a7716b72cdb49e3"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ga0838947193e222a9f46b582e01e5beff"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__lwip__opts__mem.html#ga0838947193e222a9f46b582e01e5beff">MEMP_SANITY_CHECK</a>   0</td></tr> <tr class="separator:ga0838947193e222a9f46b582e01e5beff"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ga69de593b8ffd4f1c249f03e48e11983b"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__lwip__opts__mem.html#ga69de593b8ffd4f1c249f03e48e11983b">MEMP_USE_CUSTOM_POOLS</a>   0</td></tr> <tr class="separator:ga69de593b8ffd4f1c249f03e48e11983b"><td class="memSeparator" colspan="2"> </td></tr> </table> <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> <h2 class="groupheader">Macro Definition Documentation</h2> <a id="ga0a3ef6098813c103e5aba07da76e15e2"></a> <h2 class="memtitle"><span class="permalink"><a href="#ga0a3ef6098813c103e5aba07da76e15e2">◆ </a></span>LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT   0</td> </tr> </table> </div><div class="memdoc"> <p>Set this to 1 if you want to free PBUF_RAM pbufs (or call <a class="el" href="mem_8h.html#a2fd7aa1adf6e394d3be7c7734e7df41a">mem_free()</a>) from interrupt context (or another context that doesn't allow waiting for a semaphore). If set to 1, mem_malloc will be protected by a semaphore and SYS_ARCH_PROTECT, while mem_free will only use SYS_ARCH_PROTECT. mem_malloc SYS_ARCH_UNPROTECTs with each loop so that mem_free can run.</p> <p>ATTENTION: As you can see from the above description, this leads to dis-/ enabling interrupts often, which can be slow! Also, on low memory, mem_malloc can need longer.</p> <p>If you don't want that, at least for NO_SYS=0, you can still use the following functions to enqueue a deallocation call which then runs in the tcpip_thread context:</p><ul> <li>pbuf_free_callback(p);</li> <li>mem_free_callback(m); </li> </ul> <p class="definition">Definition at line <a class="el" href="opt_8h_source.html#l00287">287</a> of file <a class="el" href="opt_8h_source.html">opt.h</a>.</p> </div> </div> <a id="ga97343214666ee6dcb18c0bd77b441ea7"></a> <h2 class="memtitle"><span class="permalink"><a href="#ga97343214666ee6dcb18c0bd77b441ea7">◆ </a></span>MEM_ALIGNMENT</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define MEM_ALIGNMENT   1</td> </tr> </table> </div><div class="memdoc"> <p>MEM_ALIGNMENT: should be set to the alignment of the CPU 4 byte alignment -> #define MEM_ALIGNMENT 4 2 byte alignment -> #define MEM_ALIGNMENT 2 </p> <p class="definition">Definition at line <a class="el" href="opt_8h_source.html#l00208">208</a> of file <a class="el" href="opt_8h_source.html">opt.h</a>.</p> </div> </div> <a id="ga4ef345cc270912bd2230b1c5ec51dfc8"></a> <h2 class="memtitle"><span class="permalink"><a href="#ga4ef345cc270912bd2230b1c5ec51dfc8">◆ </a></span>MEM_LIBC_MALLOC</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define MEM_LIBC_MALLOC   0</td> </tr> </table> </div><div class="memdoc"> <p>MEM_LIBC_MALLOC==1: Use malloc/free/realloc provided by your C-library instead of the lwip internal allocator. Can save code size if you already use it. </p> <p class="definition">Definition at line <a class="el" href="opt_8h_source.html#l00186">186</a> of file <a class="el" href="opt_8h_source.html">opt.h</a>.</p> </div> </div> <a id="ga2dcf8c45f945dd0c4301a94700f2112c"></a> <h2 class="memtitle"><span class="permalink"><a href="#ga2dcf8c45f945dd0c4301a94700f2112c">◆ </a></span>MEM_SIZE</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define MEM_SIZE   1600</td> </tr> </table> </div><div class="memdoc"> <p>MEM_SIZE: the size of the heap memory. If the application will send a lot of data that needs to be copied, this should be set high. </p> <p class="definition">Definition at line <a class="el" href="opt_8h_source.html#l00216">216</a> of file <a class="el" href="opt_8h_source.html">opt.h</a>.</p> </div> </div> <a id="gaddca3141bc7037241769eb152b6f89ba"></a> <h2 class="memtitle"><span class="permalink"><a href="#gaddca3141bc7037241769eb152b6f89ba">◆ </a></span>MEM_USE_POOLS</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define MEM_USE_POOLS   0</td> </tr> </table> </div><div class="memdoc"> <p>MEM_USE_POOLS==1: Use an alternative to malloc() by allocating from a set of memory pools of various sizes. When mem_malloc is called, an element of the smallest pool that can provide the length needed is returned. To use this, MEMP_USE_CUSTOM_POOLS also has to be enabled. </p> <p class="definition">Definition at line <a class="el" href="opt_8h_source.html#l00247">247</a> of file <a class="el" href="opt_8h_source.html">opt.h</a>.</p> </div> </div> <a id="gaba8be68e8fd0716b723ce4569ed89f82"></a> <h2 class="memtitle"><span class="permalink"><a href="#gaba8be68e8fd0716b723ce4569ed89f82">◆ </a></span>MEM_USE_POOLS_TRY_BIGGER_POOL</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define MEM_USE_POOLS_TRY_BIGGER_POOL   0</td> </tr> </table> </div><div class="memdoc"> <p>MEM_USE_POOLS_TRY_BIGGER_POOL==1: if one malloc-pool is empty, try the next bigger pool - WARNING: THIS MIGHT WASTE MEMORY but it can make a system more reliable. </p> <p class="definition">Definition at line <a class="el" href="opt_8h_source.html#l00255">255</a> of file <a class="el" href="opt_8h_source.html">opt.h</a>.</p> </div> </div> <a id="gae93af697d27bbcefa6a28052d90f2f38"></a> <h2 class="memtitle"><span class="permalink"><a href="#gae93af697d27bbcefa6a28052d90f2f38">◆ </a></span>MEMP_MEM_MALLOC</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define MEMP_MEM_MALLOC   0</td> </tr> </table> </div><div class="memdoc"> <p>MEMP_MEM_MALLOC==1: Use mem_malloc/mem_free instead of the lwip pool allocator. Especially useful with MEM_LIBC_MALLOC but handle with care regarding execution speed (heap alloc can be much slower than pool alloc) and usage from interrupts (especially if your netif driver allocates PBUF_POOL pbufs for received frames from interrupt)! ATTENTION: Currently, this uses the heap for ALL pools (also for private pools, not only for internal pools defined in <a class="el" href="memp__std_8h.html">memp_std.h</a>)! </p> <p class="definition">Definition at line <a class="el" href="opt_8h_source.html#l00199">199</a> of file <a class="el" href="opt_8h_source.html">opt.h</a>.</p> </div> </div> <a id="ga27fdd01194a42fc41a7716b72cdb49e3"></a> <h2 class="memtitle"><span class="permalink"><a href="#ga27fdd01194a42fc41a7716b72cdb49e3">◆ </a></span>MEMP_OVERFLOW_CHECK</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define MEMP_OVERFLOW_CHECK   0</td> </tr> </table> </div><div class="memdoc"> <p>MEMP_OVERFLOW_CHECK: memp overflow protection reserves a configurable amount of bytes before and after each memp element in every pool and fills it with a prominent default value. MEMP_OVERFLOW_CHECK == 0 no checking MEMP_OVERFLOW_CHECK == 1 checks each element when it is freed MEMP_OVERFLOW_CHECK >= 2 checks each element in every pool every time <a class="el" href="memp_8h.html#a2b00593d086313c267b54a976bf67aa5">memp_malloc()</a> or <a class="el" href="memp_8h.html#aecd94926b7c2a0e23ae195f4ae97581f">memp_free()</a> is called (useful but slow!) </p> <p class="definition">Definition at line <a class="el" href="opt_8h_source.html#l00229">229</a> of file <a class="el" href="opt_8h_source.html">opt.h</a>.</p> </div> </div> <a id="ga0838947193e222a9f46b582e01e5beff"></a> <h2 class="memtitle"><span class="permalink"><a href="#ga0838947193e222a9f46b582e01e5beff">◆ </a></span>MEMP_SANITY_CHECK</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define MEMP_SANITY_CHECK   0</td> </tr> </table> </div><div class="memdoc"> <p>MEMP_SANITY_CHECK==1: run a sanity check after each <a class="el" href="memp_8h.html#aecd94926b7c2a0e23ae195f4ae97581f">memp_free()</a> to make sure that there are no cycles in the linked lists. </p> <p class="definition">Definition at line <a class="el" href="opt_8h_source.html#l00237">237</a> of file <a class="el" href="opt_8h_source.html">opt.h</a>.</p> </div> </div> <a id="ga69de593b8ffd4f1c249f03e48e11983b"></a> <h2 class="memtitle"><span class="permalink"><a href="#ga69de593b8ffd4f1c249f03e48e11983b">◆ </a></span>MEMP_USE_CUSTOM_POOLS</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define MEMP_USE_CUSTOM_POOLS   0</td> </tr> </table> </div><div class="memdoc"> <p>MEMP_USE_CUSTOM_POOLS==1: whether to include a user file lwippools.h that defines additional pools beyond the "standard" ones required by lwIP. If you set this to 1, you must have lwippools.h in your include path somewhere. </p> <p class="definition">Definition at line <a class="el" href="opt_8h_source.html#l00265">265</a> of file <a class="el" href="opt_8h_source.html">opt.h</a>.</p> </div> </div> </div><!-- contents --> </div><!-- doc-content --> <!-- start footer part --> <div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> <ul> <li class="footer">Generated by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.16 </li> </ul> </div> </body> </html>