Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/satishbabariya/go-memory-profiling

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/satishbabariya/go-memory-profiling

  • v0.0.0-20200522172453-44912ef66377
  • Source
  • Go
  • Socket score

Version published
Created
Source

go-memory-profiling

add profiling into the main() function of your command

package main

import (
   //...
   "github.com/pkg/profile"
)

func main() {
   // Memory profiling
   defer profile.Start(profile.MemProfile).Stop()

   //...
}

build and run your program

This will generate a *.pprof file in a temp folder, and tell you where it’s located (will be needed later)

2017/08/03 14:26:28 profile: cpu profiling enabled, /var/...../cpu.pprof

install graphviz if you don’t have it installed yet

This is used to generate the graph on a pdf. On a Mac, it’s a simple brew install graphviz. Refer to https://www.graphviz.org for other platforms.

run go tool pprof

Pass your binary location, and the location of the cpu.pprof file as returned when running your program.

You can generate the analysis in various formats. The PDF one is pretty amazing:

go tool pprof --pdf ~/go/bin/yourbinary /var/path/to/cpu.pprof > file.pdf

FAQs

Package last updated on 22 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc