Skip to content

Commit 908cbd1

Browse files
att
1 parent 36fc2eb commit 908cbd1

File tree

4 files changed

+45
-9
lines changed

4 files changed

+45
-9
lines changed

exemples/evaluation/memory_usage.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include "LuaCEmbed.h"
2+
LuaCEmbedNamespace lua_n;
3+
4+
5+
6+
int main(int argc, char *argv[]){
7+
8+
lua_n = newLuaCEmbedNamespace();
9+
LuaCEmbed * l = lua_n.newLuaEvaluation();
10+
int one_mega = 1;
11+
lua_n.set_memory_limit(l,one_mega);
12+
lua_n.evaluate(l,"t = 'a';while true do t = t .. t end");
13+
14+
if(lua_n.has_errors(l)){
15+
printf("error: %s\n",lua_n.get_error_message(l));
16+
}
17+
18+
lua_n.free(l);
19+
20+
return 0;
21+
}

teste.lua

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1 @@
1-
2-
i = 0;
3-
limit = 10000;
4-
valores = {}
5-
while i < limit do
6-
i = i +1
7-
valores[i] = 'aaaaaaaaaa'
8-
end
9-
print('terminou')
1+
t = 'a';while true do t = t .. t end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include "../../../LuaCEmbed.h"
2+
LuaCEmbedNamespace lua_n;
3+
4+
5+
6+
int main(int argc, char *argv[]){
7+
8+
lua_n = newLuaCEmbedNamespace();
9+
LuaCEmbed * l = lua_n.newLuaEvaluation();
10+
int one_mega = 1;
11+
lua_n.set_memory_limit(l,one_mega);
12+
lua_n.evaluate(l,"t = 'a';while true do t = t .. t end");
13+
14+
if(lua_n.has_errors(l)){
15+
printf("error: %s\n",lua_n.get_error_message(l));
16+
}
17+
18+
lua_n.free(l);
19+
20+
return 0;
21+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
error: not enough memory

0 commit comments

Comments
 (0)