diff --git a/channeldb/db.go b/channeldb/db.go index e9a9a185..0fa3953f 100644 --- a/channeldb/db.go +++ b/channeldb/db.go @@ -135,7 +135,14 @@ func Open(dbPath string, modifiers ...OptionModifier) (*DB, error) { modifier(&opts) } - bdb, err := bbolt.Open(path, dbFilePermission, nil) + // Specify bbolt freelist options to reduce heap pressure in case the + // freelist grows to be very large. + options := &bbolt.Options{ + NoFreelistSync: true, + FreelistType: bbolt.FreelistMapType, + } + + bdb, err := bbolt.Open(path, dbFilePermission, options) if err != nil { return nil, err } diff --git a/watchtower/wtdb/db_common.go b/watchtower/wtdb/db_common.go index 63bca9ae..ed6f1c6b 100644 --- a/watchtower/wtdb/db_common.go +++ b/watchtower/wtdb/db_common.go @@ -63,7 +63,14 @@ func createDBIfNotExist(dbPath, name string) (*bbolt.DB, bool, error) { } } - bdb, err := bbolt.Open(path, dbFilePermission, nil) + // Specify bbolt freelist options to reduce heap pressure in case the + // freelist grows to be very large. + options := &bbolt.Options{ + NoFreelistSync: true, + FreelistType: bbolt.FreelistMapType, + } + + bdb, err := bbolt.Open(path, dbFilePermission, options) if err != nil { return nil, false, err }