内存管理
小于 1 分钟hyperlanewebrustusage-introductionleaked
提示
hyperlane 框架为了避免不必要的内存开销和系统间调用,Context 分配在堆上,需要手动管理内存,框架默认在请求完成后自动调用 ctx.free() 进行内存回收。如果需要避免框架自动回收,可以设置 ctx.set_leaked(true) 来实现,注意后续需要显示调用 ctx.free() 进行内存回收,避免内存泄漏。
内存管理
async fn handle(self, ctx: &mut Context) {
ctx.set_leaked(true);
ctx.free();
}