mirror of
https://github.com/libp2p/go-libp2p-resource-manager.git
synced 2025-03-10 17:20:39 +08:00
sanity check ReleaseMemory as well
This commit is contained in:
parent
56da0ac34f
commit
61d2f1c8ce
5
scope.go
5
scope.go
@ -57,6 +57,11 @@ func (rc *ResourceScope) ReleaseMemory(size int) {
|
|||||||
defer rc.Unlock()
|
defer rc.Unlock()
|
||||||
|
|
||||||
rc.memory -= int64(size)
|
rc.memory -= int64(size)
|
||||||
|
|
||||||
|
// sanity check for bugs upstream
|
||||||
|
if rc.memory < 0 {
|
||||||
|
panic("BUG: too much memory released")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rc *ResourceScope) GetBuffer(size int) ([]byte, error) {
|
func (rc *ResourceScope) GetBuffer(size int) ([]byte, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user