如何可视化堆转储? [英] How to visualize heapdump?

查看:127
本文介绍了如何可视化堆转储?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经开发了使用golang的服务器,该服务器将接收并发请求并处理该请求(创建大对象-树),然后发送回答复。但是对象不是垃圾收集的。因此,我决定分析内存中存在的对象。首先,我编写了一个简单程序

We have developed a server using golang which will receive concurrent request and process the request(creates big object - a tree) and then send back reply. But the objects are not garbage collected. So I decided to analyze the objects that live in the memory. To start with, I wrote a simple program

package main

import (
    "fmt"
    "io/ioutil"
    "os"
    "runtime/debug"
)

func main() {
    var i_am_a int = 10
    _ = i_am_a
    func() {
        f, err := os.Create("dump")
        defer f.Close()
        if err != nil {
            panic(err)
        }
        debug.WriteHeapDump(f.Fd())
    }()

    b, err := ioutil.ReadFile("dump")
    if err != nil {
        panic(err)
    }
    fmt.Print(string(b))

}

但是我听不懂代表语( https://github.com/golang/go/wiki/heapdump13 -这没有帮助)。我想要的只是从内存(大对象)追溯到保存对象根地址的位置(go应用程序代码中的变量)。这样我就可以发布参考,并让GC在周期内收集它。是否有最新的工具来可视化堆转储?还是有解决这个问题的更好方法?

But I couldn't understand the representaion(https://github.com/golang/go/wiki/heapdump13 - this didn't help). All I wanted is to trace back from the memory(big object) to the place(variable in go app code) which holds the root address of the object. So that I can release the reference and let GC to collect it in it's cycle. Is there a latest tool to visualize heapdump? or Is there a better approach to this problem?

推荐答案

目前,还没有完整的解决方案来解决您的问题。 最新的堆转储格式说明,运行时不再跟踪以前可用的某些信息。

There is, currently, no complete solution to your problem. The newest heap dump format explains that some information previously available is no longer tracked by the runtime.

发行16410 包含许多有关正在进行的工作的详细信息。

Go Issue 16410 has lots of details and information on work in progress.

一个工具-正在进行的工作- goheapdump

One tool - a work in progress - that may help is goheapdump

这篇关于如何可视化堆转储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆