aardio中的collectgarbage垃圾回收机制是怎么样的?
aardio中的垃圾回收使用collectgarbage()函数,
它有两个参数,
第一个参数是指定要进行什么操作,
第二个参数是对此操作的数值.
import win.ui;
/*DSG{{*/
var winform = win.form(text="aardio教程 - www.jianma123.com 简码编程";right=759;bottom=469)
winform.add(
button={cls="button";text="重启垃圾收集器";left=224;top=40;right=503;bottom=77;z=1};
button2={cls="button";text="查询内存占用Kb";left=224;top=95;right=503;bottom=132;z=2};
button3={cls="button";text="完全垃圾收集";left=224;top=149;right=503;bottom=186;z=3};
button4={cls="button";text="禁用垃圾收集器";left=224;top=203;right=503;bottom=240;z=4};
button5={cls="button";text="垃圾收集";left=224;top=257;right=503;bottom=294;z=5};
button6={cls="button";text="垃圾收集中断量";left=224;top=311;right=503;bottom=348;z=6};
button7={cls="button";text="垃圾收集工作量";left=224;top=366;right=503;bottom=403;z=7}
)
/*}}*/
winform.button.oncommand = function(id,event){
collectgarbage("restart")//重启垃圾收集器
}
winform.button2.oncommand = function(id,event){
collectgarbage("count")//查询内存占用Kb
}
winform.button3.oncommand = function(id,event){
collectgarbage("collect")//完全垃圾收集
}
winform.button4.oncommand = function(id,event){
collectgarbage("stop")//禁用垃圾收集器
}
winform.button5.oncommand = function(id,event){
collectgarbage("step",1)//垃圾收集
}
winform.button6.oncommand = function(id,event){
collectgarbage("steppause",1)//垃圾收集中断量 1~100
}
winform.button7.oncommand = function(id,event){
collectgarbage("setstepmul",2)//垃圾收集工作量 1~100
}
winform.show();
win.loopMessage();