mirror of
https://github.com/elua/elua.git
synced 2025-01-25 01:02:54 +08:00
17487f9ebe
- This should actually be a merge but we made a mistake on the initial repo creation and a merge was not possible. - Below there is a resumed log of the commit messages for the few steps, just for the record. - The merged commit messages for this work are: - Removing Portuguese doc content - Ignore folder names fixed on .gitignore - Removed doc files which content migrated to the CMS - docdata.lua updated accordingly - Doc build checked ok - Overall doc structure and contents still being refined - Removing folder cache from git versioning - Removing folder dist from git versioning. The folders above are generated by the buildall.lua script and are not part of the sources - Adding .gitignore file with objects info to inform git what to ignore - Removed file - Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git - Moving all files and folders to a working doc folder - Css updated - Index page added and CSS adjusts - Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git - Signed-off-by: Guilherme Sanchez <guilhermesanchezpacheco@gmail.com> - Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git - files deleted - Changed function that creates functions submenus. - Menu inserted with árvore, CSS adjusts, google search - Changed past design to new design - CSS updated - initial import - The commit ids were also preserved but they are related to this "other" work done on Led Lab. We'll keep the repo just in case. 4dce3f77c47b0c3001a2075a946e80ee52759b49 - Removing Portuguese doc content 78d8847525cacf045fe7e672cff6bd1e058a6a4b Ignore folder names fixed on .gitignore 48dee6b7962168ab1098bf709ead6f3cfe6b7964 - Removed doc files which content migrated to the CMS - docdata.lua updated accordingly - Doc build checked ok - Overall doc structure and contents still being refined 2aa2fe0c554db03dbc7029c34d0f4500fe625b37 - Removing folder cache from git versioning - Removing folder dist from git versioning The folders above are generated by the buildall.lua script and are not part of the sources - Adding .gitignore file with objects info to inform git what to ignore af6cc2890edf1855af319dc999a03feee5f9bee0 Removed file 6a180e72eb4f4860620cafc0685000e9f2174cfe Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git eb430112e78ae537459ab315e228ebca84bdf2d4 Moving all files and folders to a working doc folder d28a7c99489915630bd2625f3756fecf0d08ce37 Css updated 32836ffe382f04ab07c3e6f018c7b449a20d7a8d Index page added and CSS adjusts 1461d9957d9d25a1467cb57ab8717aa213a37e8d Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git ae1934c04f35a29e25bb4495ae8a31cd9c000b5b Signed-off-by: Guilherme Sanchez <guilhermesanchezpacheco@gmail.com> b5f31d70f1fac8d3fba325c9867a03f976775698 Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git ec9ad8446b7ea38b252c6a416e70774349835e45 files deleted bd7a80151b2030720ba8d8a303467d8c25a4b4b2 Changed function that creates functions submenus. 6a7494acaec694fadbb13520bcbccc51a6b95dfe Inserido menu com árvore, ajustes no CSS, busca do google e979f1c259d425c9a3be83f9cda20eddffe073bb Changed past design to new design. 381459e95286886b052103a0253e60b29e064d7a CSS updated 4f81d2f1195efe733fe5f97517be325d75937bc3 initial import
39 lines
3.5 KiB
HTML
39 lines
3.5 KiB
HTML
$$HEADER$$
|
|
<h3>Using the EGC patch with eLua</h3>
|
|
<p>The EGC (Emergency Garbage Collector) patch was originally written for Lua by Robert Jakabosky, who was kind enough to port it to <b>eLua</b>. You can find the author's detailed
|
|
description of the patch <a href="http://lua-users.org/wiki/EmergencyGarbageCollector">here</a>. In short, what it does is that it lets you run a garbage collection cycle in Lua in a low memory
|
|
situation, from inside Lua's memory allocation function (something that the current version of Lua can't do out of the box). By forcing a garbage collection cycle, Lua can reclaim memory that's
|
|
not in use anymore, thus making more memory available for your program. The downside is reduced execution speed, as a direct result of running the gargabe collector when needed. For some
|
|
applications, reducing the execution speed to fit the application in memory might be acceptable, and for other applications it might not. As usual, it all depends on your application. As a generic
|
|
guideline, if your application isn't concerned with realtime processing, you should be fine with sacrifing execution speed to get more memory in many real life scenarios.</p>
|
|
<p>In <b>eLua</b>, the EGC patch can be configured to run in 4 different modes:</p>
|
|
<ol>
|
|
<li><b>disabled</b>: EGC inactive, no collection cycle will be forced in low memory situations.</li>
|
|
<li><b>run on allocation failure</b>: try to allocate a new block of memory, and run the garbage collector if the allocation fails. If the allocation fails even after running the garbage
|
|
collector, the allocator will return with error. </li>
|
|
<li><b>run on memory limit</b>: run the garbage collector when the memory used by the Lua script goes beyond an upper limit. If the upper limit can't be satisfied even after running
|
|
the garbage collector, the allocator will return with error.</li>
|
|
<li><b>run before each allocation</b>: run the garbage collector before each memory allocation. If the allocation fails even after running the garbage collector, the allocator will
|
|
return with error. This mode is very efficient with regards to memory savings, but it's also the slowest.</li>
|
|
</ol>
|
|
<p><b>eLua</b> lets you use any of the above modes, or combine modes 2-4 above as needed. The C code API for EGC interfacing is defined in <i>src/lua/legc.h</i>, shown partially below:</p>
|
|
<p><pre><code>// EGC operations modes
|
|
#define EGC_NOT_ACTIVE 0 // EGC disabled
|
|
#define EGC_ON_ALLOC_FAILURE 1 // run EGC on allocation failure
|
|
#define EGC_ON_MEM_LIMIT 2 // run EGC when an upper memory limit is hit
|
|
#define EGC_ALWAYS 4 // always run EGC before an allocation
|
|
|
|
void legc_set_mode(lua_State *L, int mode, unsigned limit);</code></pre></p>
|
|
<p>To set the EGC operation mode, call <i>legc_set_mode</i> above with 3 parameters:</p>
|
|
<ul>
|
|
<li><b>L</b>: a pointer to a Lua state structure.</li>
|
|
<li><b>mode</b>: EGC operation mode, as described by the <b>#define</b> section above. You can specifiy a single mode, or a bitwise OR combination between <b>EGC_ON_ALLOC_FAILURE</b>,
|
|
<b>EGC_ON_MEM_LIMIT</b> and <b>EGC_ALWAYS</b>.</li>
|
|
<li><b>memlimit</b>: the upper memory limit used by the <b>EGC_ON_MEM_LIMIT</b> mode. Must be higher than 0 for this mode to run properly, can be 0 for any other mode.</li>
|
|
</ul>
|
|
|
|
<p>The functionality of this C function is mirrored by the <b>elua</b> generic module <b>egc_setup</b> function, see <a href="refman_gen_elua.html#elua.egc_setup">here</a> for more details.
|
|
Also, see <a href="building.html#static">here</a> for details on how to configure the default (compile time) EGC behaviour.</p>
|
|
$$FOOTER$$
|
|
|