Documentation
¶
Index ¶
Constants ¶
View Source
const ( // MaxBufferSize is the maximum buffer capacity before dropping. // Buffers larger than this are discarded to prevent memory bloat. MaxBufferSize = 1 << 20 // 1 MiB // DefaultCapacity is the initial capacity hint for new buffers. // This reduces reallocations for typical log entry sizes. DefaultCapacity = 512 // 512 bytes )
Configuration constants for buffer pool behavior
Variables ¶
This section is empty.
Functions ¶
func Get ¶
Get restituisce un *bytes.Buffer pulito (Reset) dal pool. Incrementa automaticamente le statistiche e garantisce che il buffer sia pronto per l'uso immediato senza contenuti precedenti.
func Put ¶
Put restituisce il buffer al pool. Se il buffer è cresciuto troppo, lo azzera per evitare growth non controllato della memoria. Questa strategia bilancia performance e utilizzo memoria.
func ResetStats ¶
func ResetStats()
ResetStats resets all pool statistics to zero. Useful for benchmarking and testing scenarios.
Types ¶
type Stats ¶
type Stats struct {
Gets int64 // Total number of Get() calls
Puts int64 // Total number of Put() calls
Allocations int64 // Total number of new buffer allocations
Drops int64 // Total number of oversized buffers dropped
}
Stats returns current buffer pool statistics for monitoring. Useful for debugging memory usage and pool efficiency.
Click to show internal directories.
Click to hide internal directories.