A Garbage Collector System and also mangament manual of memory.
◆ cache()
| local function cache |
( |
key | , |
|
|
load_func | , |
|
|
unload_func | ) |
- Example
local function slow_function()
return 1 + 1
end
local function loop(std, game)
if std.key.press.a then
local result = std.mem.
cache('slow-function', slow_function)
end
end
local function draw(src, pos_x, pos_y)
local function cache(key, load_func, unload_func)
◆ cache_get()
| local function cache_get |
( |
key | | ) |
|
◆ cache_set()
| local function cache_set |
( |
key | , |
|
|
load_func | , |
|
|
unload_func | ) |
◆ gc_clear_all()
| local function gc_clear_all |
( |
| ) |
|
- Warning
- Do not use it frequently as
loop() or draw(), but at strategic points such as changing games or world. This will clear all allocated memory, such as images, fonts, audios and things defined by you.
- Example
local function load_game(url)
std.http.get(url)
std.mem.gc_clear_all()
game.application = std.node.load(std.http.body)
std.node.spawn(game.application)
end)
:run()
end
local function success(handler_func)
◆ unset()
| local function unset |
( |
key | | ) |
|
- Example
local function slow_function()
return 1 + 1
end
local function loop(std, game)
if std.key.press.b then
std.mem.
unset('slow-function')
end
end
local function unset(key)