Gly Game Engine 0.0.7
Game engine in lua
Loading...
Searching...
No Matches
Mem

Memory Manager. More...

Collaboration diagram for Mem:

Functions

local function cache (key, load_func, unload_func)
 
local function unset (key)
 
local function gc_clear_all ()
 

Detailed Description

A Garbage Collector System and also mangament manual of memory.

Function Documentation

◆ 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)
:success(function(std, game)
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)