[Golang] How to check for memory leaks (1)

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed. [Root@s3 twitter]# Go tool pprof http://localhost:6060/debug/pprof/heap--text
Read Http://localhost:6060/debug/pprof/symbol
Fetching/pprof/heap profile from localhost:6060 to
/tmp/76z7mntrzo
Wrote profile To/tmp/76z7mntrzo
Adjusting heap profiles for 1-in-524288 sampling rate
total:47.5 MB
24.5 51.6% 51.6% 24.5 51.6% Reflect.unsafe_newarray
23.0 48.4% 100.0% 23.0 48.4% database/sql.convertassign
0.0 0.0% 100.0% 23.0 48.4% database/sql. (*rows). Scan
0.0 0.0% 100.0% 47.5 100.0% Github.com/coopernurse/gorp. (*dbmap). Select
0.0 0.0% 100.0% 47.5 100.0% github.com/coopernurse/gorp.hookedselect
0.0 0.0% 100.0% 47.5 100.0% github.com/coopernurse/gorp.rawselect
0.0 0.0% 100.0% 47.5 100.0% main.gettwitternoparse
0.0 0.0% 100.0% 27.5 57.9% Main.main
0.0 0.0% 100.0% 47.5 100.0% main.parsehtml
0.0 0.0% 100.0% 24.5 51.6% reflect. Append
0.0 0.0% 100.0% 24.5 51.6% reflect. Makeslice
0.0 0.0% 100.0% 24.5 51.6% Reflect.grow
0.0 0.0% 100.0% 1.4 2.9% Runtime. Mprof_malloc
0.0 0.0% 100.0% 1.4 2.9% runtime.callers
0.0 0.0% 100.0% 25.1 52.8% runtime.gosched0

0.0 0.0% 100.0% 26.8 56.4% Runtime.main


[Root@s3 twitter]# Go tool pprof http://localhost:6060/debug/pprof/heap--text
Read Http://localhost:6060/debug/pprof/symbol
Fetching/pprof/heap profile from localhost:6060 to
/tmp/6rfif3xdyb
Wrote profile To/tmp/6rfif3xdyb
Adjusting heap profiles for 1-in-524288 sampling rate
total:57.1 MB
30.1 52.7% 52.7% 30.1 52.7% Reflect.unsafe_newarray
27.0 47.3% 100.0% 27.0 47.3% database/sql.convertassign
0.0 0.0% 100.0% 27.0 47.3% database/sql. (*rows). Scan
0.0 0.0% 100.0% 57.1 100.0% Github.com/coopernurse/gorp. (*dbmap). Select
0.0 0.0% 100.0% 57.1 100.0% github.com/coopernurse/gorp.hookedselect
0.0 0.0% 100.0% 57.1 100.0% github.com/coopernurse/gorp.rawselect
0.0 0.0% 100.0% 57.1 100.0% main.gettwitternoparse
0.0 0.0% 100.0% 27.5 48.2% Main.main
0.0 0.0% 100.0% 57.1 100.0% main.parsehtml
0.0 0.0% 100.0% 30.1 52.7% reflect. Append
0.0 0.0% 100.0% 30.1 52.7% reflect. Makeslice
0.0 0.0% 100.0% 30.1 52.7% reflect.grow
0.0 0.0% 100.0% 1.4 2.5% Runtime. Mprof_malloc
0.0 0.0% 100.0% 1.4 2.5% runtime.callers
0.0 0.0% 100.0% 25.1 44.0% runtime.gosched0
0.0 0.0% 100.0% 26.8 46.9% Runtime.main


Memory consumption is increasing!

(pprof) Top
total:94.1 MB
49.6 52.7% 52.7% 49.6 52.7% Reflect.unsafe_newarray
44.5 47.3% 100.0% 44.5 47.3% database/sql.convertassign
0.0 0.0% 100.0% 44.5 47.3% database/sql. (*rows). Scan

Generate SVG, you have to install Graphviz, the browser opens SVG, the diagram is very clear.

Yum Install graphviz-y

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.