当前位置: 首页 > article >正文

go使用gopprof分析内存泄露

        假设我们使用的是比如beego这样的网络框架,我们可以这样加代码来使用gopprof来进行内存泄露分析:

beego框架加gopprof分析代码:

1.先在router.go里添加路由信息:

beego.Router("/debug/pprof", &controllers.ProfController{})
beego.Router("/debug/pprof/:app([\\w]+)", &controllers.ProfController{})

2.在controller里添加接口处理:

type ProfController struct {
    beego.Controller
}

func (this *ProfController) Get() {
	switch this.Ctx.Input.Param(":app") {
    default:
        pprof.Index(this.Ctx.ResponseWriter, this.Ctx.Request)
    case "":
        pprof.Index(this.Ctx.ResponseWriter, this.Ctx.Request)
    case "cmdline":
        pprof.Cmdline(this.Ctx.ResponseWriter, this.Ctx.Request)
    case "profile":
        pprof.Profile(this.Ctx.ResponseWriter, this.Ctx.Request)
    case "symbol":
        pprof.Symbol(this.Ctx.ResponseWriter, this.Ctx.Requ

http://www.kler.cn/a/227618.html

相关文章:

  • 汽车租赁系统
  • IP地址查询网络威胁:解析威胁、防范攻击
  • DS:时间复杂度和空间复杂度
  • 【51单片机系列】中断优先级介绍及使用
  • Unity | Spine动画记录
  • 2024美赛C题完整解题教程及代码 网球运动的势头
  • [Android] 240204批量生成联系人,短信,通话记录的APK
  • R语言入门笔记2.0
  • 关于服务器解析A记录和CNAME记录的分析
  • Java 数据结构 二叉树(一)二叉查询树
  • [SWPUCTF 2021 新生赛]ez_unserialize
  • 蓝桥杯备战(AcWing算法基础课)-高精度-乘-低精度
  • 【动态规划】【树形dp】【C++算法】968监控二叉树
  • 力扣:77. 组合
  • 【如何快速上手Vue.js框架——详细介绍】
  • MySQL-----DML基础操作
  • react 使用react-seamless-scroll实现无缝滚动
  • python爬虫6—高性能异步爬虫
  • Netflix Mac(奈飞mac客户端) v2.13.0激活版
  • 软件测试Bug系列之4个基本步骤(一)