Suspected memory leak with pysnmp==4.4.1 on PyPy 5.9 only (Python seems fine)
Created originally on Bitbucket by initialed85 (Edward Beech)
The code to reproduce is fairly simple- obviously you'll need PyPy 5.9 installed first as well as pysnmp==4.4.1.
#!python
from pysnmp.hlapi import SnmpEngine, UdpTransportTarget, ContextData, ObjectType, ObjectIdentity, getCmd, UsmUserData, usmHMACSHAAuthProtocol, usmAesCfb128Protocol
ITERATIONS = 65536
for i in range(0, ITERATIONS):
snmp_engine = SnmpEngine()
context_data = ContextData()
errorIndication, errorStatus, errorIndex, varBinds = next(
getCmd(
snmp_engine,
UsmUserData(
userName='some_username',
authKey='some_auth_key',
privKey='some_priv_key,
authProtocol=usmHMACSHAAuthProtocol,
privProtocol=usmAesCfb128Protocol,
),
UdpTransportTarget(
('some_host', 161),
timeout=5,
retries=2,
),
context_data,
ObjectType(ObjectIdentity('.1.3.6.1.2.1.1.5.0'))
)
)
print '{0}/{1} - {2}'.format(i + 1, ITERATIONS, varBinds)
del snmp_engine
del context_data
Under PyPy 5.9 memory use steadily increases until (in my experience) MacOS crashes; in Python however, all seems fine.
I've also raised an issue on the PySNMP Github page.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information