fwiw, that code works on my machine :tm:

1:40:47 ~/tmp/testrepo0120 0:00:27
main » go run .
1:40:58 ~/tmp/testrepo0120 0:00:08
main » go tool pprof mem.prof
File: testrepo0120
Type: inuse_space
Time: Mar 2, 2023 at 1:40am (CST)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) top10
Showing nodes accounting for 513.31kB, 100% of 513.31kB total
      flat  flat%   sum%        cum   cum%
  513.31kB   100%   100%   513.31kB   100%  regexp/syntax.(*compiler).inst
(inline)
         0     0%   100%   513.31kB   100%  regexp.Compile (inline)
         0     0%   100%   513.31kB   100%  regexp.MustCompile
         0     0%   100%   513.31kB   100%  regexp.compile
         0     0%   100%   513.31kB   100%
 regexp/syntax.(*compiler).compile
         0     0%   100%   513.31kB   100%  regexp/syntax.(*compiler).rune
         0     0%   100%   513.31kB   100%  regexp/syntax.Compile
         0     0%   100%   513.31kB   100%  runtime.doInit
         0     0%   100%   513.31kB   100%  runtime.main
         0     0%   100%   513.31kB   100%
seehuhn.de/go/pdf/font/tounicode.init

- sean


On Wed, Mar 1, 2023 at 11:25 PM Jochen Voss <jochen.v...@gmail.com> wrote:

> The problem also occurs on AMD64 Linux, so it's not architecture
> specific.  Hints would be most welcome!
>
> On Wednesday, 1 March 2023 at 13:55:30 UTC Jochen Voss wrote:
>
>> Dear all,
>>
>> I'm trying to profile memory use of a program, following the instructions
>> at https://go.dev/blog/pprof , but I can't get memory profiling to
>> work.  Am I doing things wrong, or is this broken?
>>
>> Simplified code is at https://go.dev/play/p/Wq_OU49LVQZ .  (The code
>> doesn't run on the playground, but you can download it and run it locally.)
>>
>> Following the advice from https://pkg.go.dev/runtime/pprof I added the
>> following code to the end of my main() function:
>>
>> f, err := os.Create("mem.prof")
>> if err != nil {
>> log.Fatal("could not create memory profile: ", err)
>> }
>> runtime.GC() // get up-to-date statistics
>> if err := pprof.WriteHeapProfile(f); err != nil {
>> log.Fatal("could not write memory profile: ", err)
>> }
>> err = f.Close()
>> if err != nil {
>> log.Fatal(err)
>> }
>>
>> When I run the code, this gives me a "mem.prof" file (5084 bytes).  But
>> when I start "go tool pprof" on this file, I get
>>
>> >>> go tool pprof xxx mem.prof
>> File: xxx
>> Type: inuse_space
>> Time: Mar 1, 2023 at 1:15pm (GMT)
>> No samples were found with the default sample value type.
>> Try "sample_index" command to analyze different sample values.
>> Entering interactive mode (type "help" for commands, "o" for options)
>> (pprof) top10
>> Showing nodes accounting for 0, 0% of 0 total
>>       flat  flat%   sum%        cum   cum%
>>
>> There seem to be no samples in this file.
>>
>> What am I doing wrong?
>>
>> All the best,
>> Jochen
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/4e85c396-ef29-41d5-9bb6-5b950648287fn%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/4e85c396-ef29-41d5-9bb6-5b950648287fn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAGabyPpMNVc8-KpNaEAMm4X7eTy7H1r92acuAj7iHuU%2BXJLtWw%40mail.gmail.com.

Reply via email to