Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory leak when creating AsyncSniffer repeatedly #4698

Open
bingwang-ms opened this issue Mar 19, 2025 · 0 comments
Open

memory leak when creating AsyncSniffer repeatedly #4698

bingwang-ms opened this issue Mar 19, 2025 · 0 comments

Comments

@bingwang-ms
Copy link

Brief description

Memory is not freed when creating AsyncSniffer repeatedly.

Test code

from scapy.all import *
import time


def process_packet(packet):
    pass

def start_sniff():
    ifaces = ["PortChannel102", "PortChannel103", "PortChannel104", "PortChannel105", "PortChannel106", "PortChannel107", "PortChannel108", "PortChannel109"]
    sniffstring = "udp and (dst host " + str("10.1.0.32") + " or dst host " + "fc00:1::32" +  ") and dst port " + str(65330)
    sniffer = AsyncSniffer(iface=ifaces, filter=sniffstring, prn=process_packet, store=False)
    sniffer.start()
    RETRY = 30
    while RETRY >= 0 and not hasattr(sniffer, 'stop_cb'):
        time.sleep(0.1)
        RETRY -= 1
    print("Sniff started")
    try:
        sniffer.stop()
    except:
        pass
    else:
        print("Sniff stopped")

def main():
    while True:
        start_sniff()
        time.sleep(1)

if __name__ == "__main__":
    main()

Scapy version

2.4.5

Python version

3.9.2

Operating system

Debian GNU/Linux 11 (bullseye)

Additional environment information

No response

How to reproduce

Run the script and monitor the memory usage

Actual result

No response

Expected result

No response

Related resources

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant