Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not store non-pointer values in sync.Pool. #4089

Merged
merged 3 commits into from
Oct 4, 2019

Commits on Sep 27, 2019

  1. Do not store non-pointer values in sync.Pool.

    A sync.Pool is used to avoid unnecessary allocations and reduce the
    amount of work the garbage collector has to do.  When passing a value
    that is not a pointer to a function that accepts an interface, the value
    needs to be placed on the heap, which means an additional allocation.
    Slices are a common thing to put in sync.Pools, and they’re structs with
    3 fields (length, capacity, and a pointer to an array). In order to
    avoid the extra allocation, one should store a pointer to the slice
    instead.
    martinmr committed Sep 27, 2019
    Configuration menu
    Copy the full SHA
    7b24c75 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    62e3118 View commit details
    Browse the repository at this point in the history

Commits on Oct 3, 2019

  1. Configuration menu
    Copy the full SHA
    be85bf4 View commit details
    Browse the repository at this point in the history