Home >Backend Development >Golang >ShrinkMap - A High-Performance Concurrent Map with Automatic Memory Management for Go
Hello Gophers! ?
I'm excited to share ShrinkMap, a new concurrent map implementation for Go that focuses on automatic memory management and performance.
https://github.com/jongyunha/shrinkmap/
ShrinkMap is a thread-safe map implementation that automatically manages memory by cleaning up unused entries while maintaining high performance for concurrent operations. It's designed to be a drop-in replacement for sync.Map when you need better memory efficiency.
package main import ( "fmt" "github.com/jongyunha/shrinkmap" ) func main() { // Create a new map sm := shrinkmap.New[string, int]() // Store values sm.Store("counter", 1) // Load values if val, ok := sm.Load("counter"); ok { fmt.Printf("Value: %d\n", val) } }
While sync.Map is great for many use cases, there are scenarios where memory management becomes crucial:
I'd love to hear your thoughts and feedback on:
The project is open for contributions! Whether it's bug reports, feature requests, or code contributions, all are welcome.
Feel free to:
Looking forward to your feedback and suggestions!
The above is the detailed content of ShrinkMap - A High-Performance Concurrent Map with Automatic Memory Management for Go. For more information, please follow other related articles on the PHP Chinese website!