Code Monkey home page Code Monkey logo

Comments (2)

syockit avatar syockit commented on July 21, 2024

Problem persists on golang 1.5.2

heap profile: 101: 1677721984 [134: 1678039600] @ heap/1048576
100: 1677721600 [100: 1677721600] @ 0x4505c5 0x4b4926 0x402561 0x40cd1b 0x46dfc1
#   0x4b4926    github.com/mumax/3/httpfs.Create+0x286  /home/syukri/gopath/src/github.com/mumax/3/httpfs/reader.go:21
#   0x402561    main.NewProcess+0x991           /home/syukri/gopath/src/github.com/mumax/3/cmd/mumax3-server/compute.go:164
#   0x40cd1b    main.RunComputeService.func1+0xcb   /home/syukri/gopath/src/github.com/mumax/3/cmd/mumax3-server/compute.go:70

Granted, most of them are virtual, and only a little percentage are reserved, but they do build up. My colleague's server has 914M RSS now after restarting yesterday.

Apparently, niling buf allows it to be GC'ed.

    // httpfs/reader.go
    func (w *bufWriter) Close() error                {
     err := w.buf.Flush() 
     if err != nil {
        return err
     }
     w.buf = nil
     return nil
    }

for which the profile now reads

heap profile: 2: 528 [138: 1677918648] @ heap/1048576
... snip ...
0: 0 [100: 1677721600] @ 0x4505c5 0x4b4926 0x402561 0x40cd1b 0x46dfc1
#   0x4b4926    github.com/mumax/3/httpfs.Create+0x286  /home/syukri/gopath/src/github.com/mumax/3/httpfs/reader.go:21
#   0x402561    main.NewProcess+0x991           /home/syukri/gopath/src/github.com/mumax/3/cmd/mumax3-server/compute.go:164
#   0x40cd1b    main.RunComputeService.func1+0xcb   /home/syukri/gopath/src/github.com/mumax/3/cmd/mumax3-server/compute.go:70

I still don't understand: why is the explicit niling necessary even when no references to it survive?

from 3.

barnex avatar barnex commented on July 21, 2024

Hmm, this looks like I might be keeping a pointer to the bufWriter somewhere. nilling the buffer frees most of its memory but may not fix the root cause.
Anyway, feel free to send a pull request with your mitigation if you like (but perhaps move the w.buf=nil up to before the if).
I'd be very surprised if this is a go GC issue.

from 3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.