Skip to content

bitswap/client: memory leak on BlockPresenceManager #574

Description

@Dreamacro

Recently, I observed that when using bitswap for fetching data, there is a large amount of memory consumption and no release after downloading.

I use pprof and find most heap is occupied here.

bpm.presence[c] = make(map[peer.ID]bool)

I try to print stat after bpm.presence[c] = make(map[peer.ID]bool) and I found bpm.presence would delete on BlockPresenceManager.RemoveKeys, so I added some logs.

I found that there is a race condition problem here.

  1. BlockPresenceManager.RemoveKeys has been called and remove the CidA
  2. BlockPresenceManager.ReceiveFrom has been called and created bpm.presence[CidA]
  3. bpm.presence[CidA] is no longer used or removed, and the map is getting bigger and bigger.

Metadata

Metadata

Assignees

Labels

P1High: Likely tackled by core team if no one steps upkind/bugA bug in existing code (including security flaws)need/analysisNeeds further analysis before proceeding

Type

No type
No fields configured for issues without a type.

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions