File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -424,6 +424,46 @@ error: timeout error
424
424
425
425
~~~
426
426
427
+ ### Memory usage
428
+ by using the method ** set_memory_limit** you can control the max ram usage of lua, the default its 100mb
429
+ <h5 style =" color :red ;" >NOTE THAT EXTRA MEMORY ALOCATED OUTSIDE CALLBACKS OR EVALUATIONS ARE CONSIDER UNPROTECTED GEHAVIOR
430
+ AND IT WILL KILL THE APPLICATION
431
+
432
+ </h5 >
433
+ <!-- codeof:exemples/evaluation/memory_usage.c-->
434
+ ~~~ c
435
+ #include " LuaCEmbed.h"
436
+ LuaCEmbedNamespace lua_n;
437
+
438
+
439
+
440
+ int main (int argc, char * argv[ ] ){
441
+
442
+ lua_n = newLuaCEmbedNamespace();
443
+ LuaCEmbed * l = lua_n.newLuaEvaluation();
444
+ int one_mega = 1;
445
+ lua_n.set_memory_limit(l,one_mega);
446
+ lua_n.evaluate(l,"t = 'a';while true do t = t .. t end");
447
+
448
+ if(lua_n.has_errors(l)){
449
+ printf("error: %s\n",lua_n.get_error_message(l));
450
+ }
451
+
452
+ lua_n.free(l);
453
+
454
+ return 0;
455
+ }
456
+ ~~~
457
+
458
+ It will produce:
459
+
460
+ <!--codeof:tests/main_test/evaluation/T_memory_usage/expected.txt-->
461
+ ~~~txt
462
+
463
+ error: not enough memory
464
+
465
+ ~~~
466
+
427
467
### Callbacks
428
468
Callbacks i'ts a way to make c functions assesible in lua code, this it's the most basic callback:
429
469
You can’t perform that action at this time.
0 commit comments