<!-- XE-13292 · [net/sync.go] M6: syncIncapable map tidak pernah dibersihkan — memory leak kecil · testnet -->
*Markdown view of <https://bounty.xe.network/XE-13292>. The page is the record; this is the same page for reading.*

XE-13292 · Bounty

# \[net/sync.go\] M6: syncIncapable map tidak pernah dibersihkan — memory leak kecil

Closed · invalid
—
[xe#437](https://github.com/xeprotocol/xe/issues/437)
filed 2026-11-12 02:51 UTC
by wahyu20260100233-ops

Verdict
:   Invalid

Tier
:   —

Claimed
:   —

Area
:   P2P / sync

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-20 00:51 UTC

Told
:   2026-11-20 00:49 UTC

### Patches

None linked.

### History

- [557725](https://bounty.xe.network/log/557725) 2026-11-20 00:49 UTC reply.mirrored
- [557088](https://bounty.xe.network/log/557088) 2026-11-20 00:48 UTC reply.sent
- [554083](https://bounty.xe.network/log/554083) 2026-11-20 00:36 UTC github.state\_pushed
- [554081](https://bounty.xe.network/log/554081) 2026-11-20 00:35 UTC github.labels
- [553360](https://bounty.xe.network/log/553360) 2026-11-20 00:33 UTC proposal.adopted
- [553172](https://bounty.xe.network/log/553172) 2026-11-20 00:33 UTC proposal.adopted
- [553171](https://bounty.xe.network/log/553171) 2026-11-20 00:33 UTC ticket.status new → closed
- [552802](https://bounty.xe.network/log/552802) 2026-11-20 00:33 UTC proposal.adopted
- [552801](https://bounty.xe.network/log/552801) 2026-11-20 00:33 UTC ticket.facts area
- [552797](https://bounty.xe.network/log/552797) 2026-11-20 00:33 UTC proposal.adopted
- [552796](https://bounty.xe.network/log/552796) 2026-11-20 00:33 UTC ticket.facts
- [550791](https://bounty.xe.network/log/550791) 2026-11-20 00:30 UTC note.added

[Full history](https://bounty.xe.network/log?ref=XE-13292) · [JSON](https://bounty.xe.network/v1/tickets/XE-13292) · [markdown](https://bounty.xe.network/XE-13292.md)

### Report

## Ringkasan

`syncIncapable` di-set di `markSyncIncapable()` tapi hanya di-clean di `removePeer()` (yang dipanggil dari `DisconnectedF`). Kalau peer tidak pernah disconnect, entry tetap ada selamanya. Tidak ada cleanup berdasarkan waktu.

## Lokasi

- File: `net/sync.go`
- Lines: 78, 153-163

## Kode

```
func (t *tracker) markSyncIncapable(pid peer.ID) {
    t.mu.Lock()
    t.syncIncapable[pid] = struct{}{}
    t.mu.Unlock()
}

func (t *tracker) removePeer(pid peer.ID) {
    t.mu.Lock()
    delete(t.syncIncapable, pid)
    t.mu.Unlock()
}
```

## Impact

Memory leak kecil (map tumbuh). Kalau ada banyak peer yang connect dan disconnect tidak pernah terjadi, map tumbuh tanpa batas.

## Suggested Fix

```
func (t *tracker) markSyncIncapable(pid peer.ID) {
    t.mu.Lock()
    t.syncIncapable[pid] = time.Now()  // simpan timestamp
    t.mu.Unlock()
}

func (t *tracker) removePeer(pid peer.ID) {
    t.mu.Lock()
    delete(t.syncIncapable, pid)
    t.mu.Unlock()
}

// tambah cleanup periodic
func (t *tracker) cleanupSyncIncapable() {
    t.mu.Lock()
    now := time.Now()
    for pid, t := range t.syncIncapable {
        if now.Sub(t) > 24*time.Hour {
            delete(t.syncIncapable, pid)
        }
    }
    t.mu.Unlock()
}
```

Atau gunakan TTL-based map.

### Thread

**XE desk**team2026-11-20 00:49 UTCgithub

Thanks for the report. We read it against the code and could not confirm a bug in what it describes.

This report is closed as invalid. If we have missed something, file a new report that links
https://bounty.xe.network/XE-13292 and says what; it is read like any other.
