{"id":13714094,"url":"https://github.com/mostynb/zstdpool-syncpool","last_synced_at":"2026-04-04T06:35:45.092Z","repository":{"id":46369516,"uuid":"315703315","full_name":"mostynb/zstdpool-syncpool","owner":"mostynb","description":"go sync.Pool wrapper for github.com/klauspost/compress/zstd which doesn't leak memory and goroutines.","archived":false,"fork":false,"pushed_at":"2023-05-07T10:25:50.000Z","size":16,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-28T07:22:44.655Z","etag":null,"topics":["compression","go","zstd"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mostynb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-24T17:19:39.000Z","updated_at":"2024-01-11T15:48:21.000Z","dependencies_parsed_at":"2024-06-19T04:11:00.919Z","dependency_job_id":null,"html_url":"https://github.com/mostynb/zstdpool-syncpool","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mostynb%2Fzstdpool-syncpool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mostynb%2Fzstdpool-syncpool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mostynb%2Fzstdpool-syncpool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mostynb%2Fzstdpool-syncpool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mostynb","download_url":"https://codeload.github.com/mostynb/zstdpool-syncpool/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248943444,"owners_count":21186958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compression","go","zstd"],"created_at":"2024-08-02T23:01:51.691Z","updated_at":"2026-04-04T06:35:45.032Z","avatar_url":"https://github.com/mostynb.png","language":"Go","readme":"[![godoc](https://godoc.org/github.com/mostynb/zstdpool-syncpool?status.svg)](http://godoc.org/github.com/mostynb/zstdpool-syncpool)\n\n# zstdpool-syncpool\n\ngithub.com/klauspost/compress/zstd is a native Go implementation of Zstandard,\nwith an API that leaks memory and goroutines if you don't call `Close()`\non every `Encoder` and `Decoder` that you create, and `Decoders` cannot be\nreused after they are closed.\n\nzstdpool-syncpool is a Go wrapper for github.com/klauspost/compress/zstd\nand sync.Pool, which automatically frees resources if you forget to call\n`Close()` and/or when items are dropped from the sync.Pool.\n\nBackground: https://github.com/klauspost/compress/issues/264\n\n# Basic usage\n\nhttps://pkg.go.dev/github.com/mostynb/zstdpool-syncpool\n\n```\nimport (\n\t\"github.com/klauspost/compress/zstd\"\n\tsyncpool \"github.com/mostynb/zstdpool-syncpool\"\n)\n\n// Create a sync.Pool which returns wrapped *zstd.Decoder's.\ndecoderPool := syncpool.NewDecoderPool(zstd.WithDecoderConcurrency(1))\n\n// Get a *DecoderWrapper and use it.\ndecoder := decoderPool.Get().(*syncpool.DecoderWrapper)\ndecoder.Reset(compressedDataReader)\n_, err = io.Copy(uncompressedDataWriter, decoder)\n\n// Return the decoder to the pool. If we forget this, then the zstd.Decoder\n// won't leak resources.\ndecoderPool.Put(decoder)\n\n\n// Create a sync.Pool which returns wrapped *zstd.Endoder's.\nencoderPool := syncpool.NewEncoderPool(zstd.WithEncoderConcurrency(1))\n\n// Get an *EncoderWrapper and use it.\nencoder := encoderPool.Get().(*syncpool.EncoderWrapper)\nencoder.Reset(compressedDataWriter)\n_, err = io.Copy(encoder, uncompressedDataReader)\n\n// Return the encoder to the pool. If we forget this, then the zstd.Encoder\n// won't leak resources.\nencoderPool.Put(encoder)\n```\n\n# Simplified usage\n\nIf you would like to avoid type assertions, you can use `NewDecoderPoolWapper`\nand `NewEncoderPoolWrapper`:\n\n```\nimport (\n\t\"github.com/klauspost/compress/zstd\"\n\tsyncpool \"github.com/mostynb/zstdpool-syncpool\"\n)\n\n// Create a sync.Pool which returns wrapped *zstd.Decoder's.\ndecoderPool := syncpool.NewDecoderPoolWrapper(zstd.WithDecoderConcurrency(1))\n\n// Get a *DecoderWrapper and use it.\ndecoder := decoderPool.Get(compressedDataReader)\n_, err = io.Copy(uncompressedDataWriter, decoder)\n\n// Return the decoder to the pool. If we forget this, then the zstd.Decoder\n// won't leak resources.\ndecoderPool.Put(decoder)\n\n// Create a sync.Pool which returns wrapped *zstd.Endoder's.\nencoderPool := syncpool.NewEncoderPoolWrapper(zstd.WithEncoderConcurrency(1))\n\n// Get an EncoderWrapper and use it.\nencoder := encoderPool.Get(compressedDataWriter)\n_, err = io.Copy(encoder, uncompressedDataReader)\n\n// Return the encoder to the pool. If we forget this, then the zstd.Encoder\n// won't leak resources.\nencoderPool.Put(encoder)\n\n```\n\n# Contributing\n\nBug reports, feature requests, PRs welcome.\n\n# License\n\nLicensed under the Apache License, Version 2.0. See the LICENSE file.\n","funding_links":[],"categories":["Repositories"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmostynb%2Fzstdpool-syncpool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmostynb%2Fzstdpool-syncpool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmostynb%2Fzstdpool-syncpool/lists"}