game_common.profiler_tools
简介
组件接口
mp_tool.gs
基于mem_profiler扩展的诊断工具
函数原型 | 函数作用 |
---|---|
void gc_search_closed_object(mixed ob_str, int max_search_round = 2) | 对给定的已经关闭的对象执行mem_profiler.gc_search |
void gc_search_closed_handle(mixed handle_value, int max_search_round = 2) | 对给定的已经关闭的handle执行mem_profiler.gc_search |
handle find_closed_handle(mixed str_or_handle_id) | 根据给定的handle id或者handle 字符串查找已经关闭的handle |
object find_closed_object(mixed ob_str_or_handle_id) | 根据给定的object handle id或者object字符串查找已经关闭的object |
map show_closed_handles(int scan_times = 10, int filter_times_less = 1) | 服务器端版本:扫描指定次数的已关闭handle列表并进行统计、分析,最后显示扫描期间未被gc回收的已关闭handle信息 |
map show_closed_objects(int scan_times = 10, int filter_times_less = 1) | 服务器端版本:扫描指定次数的已关闭对象列表并进行统计、分析,最后显示扫描期间未被gc回收的已关闭对象信息 |
void set_output_callback(function func) | 设置用于show_closed_handles()/show_closed_objects()显示输出的回调函数 |
queue_tool.gs
队列相关的诊断工具
函数原型 | 函数作用 |
---|---|
void top(int n = 5, int show_count = 10, string sort_by = "speed") | 监控队列长度变化 |
void stop() | 停止监控队列长度变化 |
search_tool.gs
对mem_profiler.gc_search的改进实现
函数原型 | 函数作用 |
---|---|
void find_ref(mixed searching_unit, int max_searching_rounds = 3) | 搜索正在引用指定目标的存活handle,并给出引用链,接口与 mem_profiler.gc_search一致,是gc_search的功能简化/优化版本 |
类
MemWatchDog
内存看门狗
成员变量
变量名 | 类型 | 初始值 | 须初始化 | 描述 |
---|
成员方法
函数原型 | 函数作用 |
---|---|
void set_log_callback(function fun) | 设置监视协程的输出回调函数 |
样例
public void pkg_sample()
{
array a = [];
map b = {0: a};
queue q = queue.create("");
q.send_raw(b);
search_tool.find_ref(a);
// 将在屏幕上打印引用关系,看起来将会类似这样:
/*
Searching for reference relationship of unit <No describe> (0x0000040005dcc460)...
Current unit has been referenced by 1 handle(s).
==========================================
queue: queue[3105024:v0]
The searched reference chain is displayed as follows:
[Searching target]
|<- map {0:[], }(0x0000040005e42480)
|<- queue queue[3105024:v0](0x0000040005ec2000)
==========================================
NOTE: Due to the limitation of gc.search's working principle, some of reference can not be displayed here.
*/
}