Skip to content

Commit

Permalink
cache: improve memory management comment
Browse files Browse the repository at this point in the history
  • Loading branch information
RaduBerinde committed Sep 2, 2024
1 parent 31f6040 commit ecdb921
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions internal/cache/clockpro.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,11 +645,16 @@ type Metrics struct {
//
// # Memory Management
//
// A normal implementation of the block cache would result in GC having to read
// through all the structures and keep track of the liveness of many objects.
// This was found to cause significant overhead in CRDB when compared to the
// earlier use of RocksDB.
//
// In order to reduce pressure on the Go GC, manual memory management is
// performed for the data stored in the cache. Manual memory management is
// performed by calling into C.{malloc,free} to allocate memory. Cache.Values
// are reference counted and the memory backing a manual value is freed when
// the reference count drops to 0.
// performed by calling into C.{malloc,free} to allocate memory; this memory is
// outside the purview of the GC. Cache.Values are reference counted and the
// memory backing a manual value is freed when the reference count drops to 0.
//
// Manual memory management brings the possibility of memory leaks. It is
// imperative that every Handle returned by Cache.{Get,Set} is eventually
Expand Down

0 comments on commit ecdb921

Please sign in to comment.