You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

github.com/libp2p/go-buffer-pool

Package Overview
Dependencies
0
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/libp2p/go-buffer-pool

Package pool provides a sync.Pool equivalent that buckets incoming requests to one of 32 sub-pools, one for each power of 2, 0-32.


Version published

Readme

Source

go-buffer-pool

codecov Travis CI Discourse posts

A variable size buffer pool for go.

Table of Contents

Use Case

Use this when you need to repeatedly allocate and free a bunch of temporary buffers of approximately the same size.

Advantages over GC

  • Reduces Memory Usage:

    • We don't have to wait for a GC to run before we can reuse memory. This is essential if you're repeatedly allocating large short-lived buffers.
  • Reduces CPU usage:

    • It takes some load off of the GC (due to buffer reuse).
    • We don't have to zero buffers (fewer wasteful memory writes).

Disadvantages over GC:

  • Can leak memory contents. Unlike the go GC, we don't zero memory.
  • All buffers have a capacity of a power of 2. This is fine if you either (a) actually need buffers with this size or (b) expect these buffers to be temporary.
  • Requires that buffers be returned explicitly. This can lead to race conditions and memory corruption if the buffer is released while it's still in use.

Contribute

PRs are welcome!

Small note: If editing the Readme, please conform to the standard-readme specification.

License

MIT © Protocol Labs BSD © The Go Authors


The last gx published version of this module was: 0.1.3: QmQDvJoB6aJWN3sjr3xsgXqKCXf4jU5zdMXpDMsBkYVNqa

FAQs

Package last updated on 01 Jul 2022

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc