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

相关推荐

  1. go使用gopprof分析内存泄露

    2024-02-04 20:16:04       34 阅读
  2. go 使用pprof查看内存分布

    2024-02-04 20:16:04       14 阅读
  3. Android 使用LeakCanary检测内存泄漏分析原因

    2024-02-04 20:16:04       13 阅读
  4. go语言内存泄漏检查工具

    2024-02-04 20:16:04       28 阅读
  5. 【Linux上使用jeprof和jemalloc分析内存泄漏的方法】

    2024-02-04 20:16:04       19 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-02-04 20:16:04       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-02-04 20:16:04       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-02-04 20:16:04       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-02-04 20:16:04       18 阅读

热门阅读

  1. Go 语言实现并发、通道原理(附带案例)

    2024-02-04 20:16:04       33 阅读
  2. 自学PyQt6杂记索引

    2024-02-04 20:16:04       30 阅读
  3. Understanding TCP Congestion Control

    2024-02-04 20:16:04       28 阅读
  4. 数据库||数据库相关知识练习题目与答案

    2024-02-04 20:16:04       28 阅读
  5. KMP算法

    2024-02-04 20:16:04       33 阅读