projects
/
project
/
luci.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7dcb05f
)
libs/core: trigger garbage collection in coxpcall() if 80% of the allocated memory...
author
Jo-Philipp Wich
<jow@openwrt.org>
Fri, 10 Jul 2009 17:38:01 +0000
(17:38 +0000)
committer
Jo-Philipp Wich
<jow@openwrt.org>
Fri, 10 Jul 2009 17:38:01 +0000
(17:38 +0000)
libs/core/luasrc/util.lua
patch
|
blob
|
history
diff --git
a/libs/core/luasrc/util.lua
b/libs/core/luasrc/util.lua
index
adeb99f
..
e86d5ec
100644
(file)
--- a/
libs/core/luasrc/util.lua
+++ b/
libs/core/luasrc/util.lua
@@
-37,6
+37,7
@@
local rawget, rawset, unpack = rawget, rawset, unpack
local tostring, type, assert = tostring, type, assert
local ipairs, pairs, loadstring = ipairs, pairs, loadstring
local require, pcall, xpcall = require, pcall, xpcall
local tostring, type, assert = tostring, type, assert
local ipairs, pairs, loadstring = ipairs, pairs, loadstring
local require, pcall, xpcall = require, pcall, xpcall
+local collectgarbage, get_memory_limit = collectgarbage, get_memory_limit
--- LuCI utility functions.
module "luci.util"
--- LuCI utility functions.
module "luci.util"
@@
-784,5
+785,11
@@
end
-- Resume execution of protected function call
function performResume(err, co, ...)
-- Resume execution of protected function call
function performResume(err, co, ...)
+ if get_memory_limit and get_memory_limit() > 0 and
+ collectgarbage("count") > (get_memory_limit() * 0.8)
+ then
+ collectgarbage("collect")
+ end
+
return handleReturnValue(err, co, coroutine.resume(co, ...))
end
return handleReturnValue(err, co, coroutine.resume(co, ...))
end