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)
std.draw.text(result)
end
end
local function cache(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.game.load(std.http.body)
game.application.init(std, game)
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)