Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
7510ef20
Commit
7510ef20
authored
Oct 29, 2014
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(cmd/ipfs1) add mem profiling in debug mode
TODO add memory profiling to ipfs2
parent
1e847059
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
cmd/ipfs/ipfs.go
cmd/ipfs/ipfs.go
+18
-0
No files found.
cmd/ipfs/ipfs.go
View file @
7510ef20
...
...
@@ -17,6 +17,8 @@ import (
u
"github.com/jbenet/go-ipfs/util"
)
const
heapProfile
=
"ipfs.mprof"
// The IPFS command tree. It is an instance of `commander.Command`.
var
CmdIpfs
=
&
commander
.
Command
{
UsageLine
:
"ipfs [<flags>] <command> [<args>]"
,
...
...
@@ -117,6 +119,13 @@ func main() {
}
os
.
Exit
(
1
)
}
if
u
.
Debug
{
err
:=
writeHeapProfileToFile
()
if
err
!=
nil
{
log
.
Critical
(
err
)
}
}
return
}
...
...
@@ -220,3 +229,12 @@ func setupDaemon(confdir string, node *core.IpfsNode) (*daemon.DaemonListener, e
go
dl
.
Listen
()
return
dl
,
nil
}
func
writeHeapProfileToFile
()
error
{
mprof
,
err
:=
os
.
Create
(
heapProfile
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
defer
mprof
.
Close
()
return
pprof
.
WriteHeapProfile
(
mprof
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment