I use the current snmp library version 8.5 but had the same problem in previous version 8.0 too.
If I call the extension method BeginGetResponse() (implemented in SnmpMessageExtension.cs) and my SNMP device is not running, there is every time a SocketException. The exception is thrown in the function BeginGetResponse() at the line "var ar = udpSocket.BeginReceive(....)".
My memory profiler shows two leaks: one in Lextm.SharpSnmpLib.Security.UserRegistry (132 Bytes) and two in Lextm.SharpSnmpLib.Messaging.SnmpMessageExt (84 and 132 Bytes).
My Application polls the SNMP devices all 2 seconds, so after 48 hours I got an OutOfMemory exception.
Please help, what could be wrong?
Comments: Thank your for the answer. I made now some small adjustments in my code to get the same as your code but the memory leak ist still there. I think it has to do with the network configuration of the system and/or the .net framework GC or the framework version. The configured target framework in my application is ".NET Framework 4.5" and installed ist Framework 4.5.2. See also the following discussions: http://www.pcreview.co.uk/threads/memory-leak-with-socket-beginreceive.2278032/ http://stackoverflow.com/questions/24268434/net-4-5-async-tcp-server-memory-leak-beginreceive-beginsend
If I call the extension method BeginGetResponse() (implemented in SnmpMessageExtension.cs) and my SNMP device is not running, there is every time a SocketException. The exception is thrown in the function BeginGetResponse() at the line "var ar = udpSocket.BeginReceive(....)".
My memory profiler shows two leaks: one in Lextm.SharpSnmpLib.Security.UserRegistry (132 Bytes) and two in Lextm.SharpSnmpLib.Messaging.SnmpMessageExt (84 and 132 Bytes).
My Application polls the SNMP devices all 2 seconds, so after 48 hours I got an OutOfMemory exception.
Please help, what could be wrong?
Comments: Thank your for the answer. I made now some small adjustments in my code to get the same as your code but the memory leak ist still there. I think it has to do with the network configuration of the system and/or the .net framework GC or the framework version. The configured target framework in my application is ".NET Framework 4.5" and installed ist Framework 4.5.2. See also the following discussions: http://www.pcreview.co.uk/threads/memory-leak-with-socket-beginreceive.2278032/ http://stackoverflow.com/questions/24268434/net-4-5-async-tcp-server-memory-leak-beginreceive-beginsend