About delete in Managed C++
-
I have an app that works the following way: 1.the main process is written in C# 2.the main process uses class witten in Managed C++ 3.in classes wirtten in Managed C++, Unmanaged C libs are called 4.as well the main process communicate with other host via .NET remoting The other day a got a socket exception says (this happens at a very low frequency): "An operation was attempted on something that is not a socket" I investegated a lot and come to know this will only happen when the TCP/IP stack is destroyed (IP addresses are all fixed) I don't think TCP/IP stack can be destroyed by codes in C#. In Managed C++, all object reference created on C#'s side were
delete objRefCreatedInCSharp;
in Dispose(). I am told this was done to prevent memory leak. My qusetion is 1. Is delete necessary to prevent memory leak? 2. Won't this delete destroy TCP/IP stack at a certain timing? Thank you very much. -- modified at 0:35 Wednesday 29th March, 2006 -
I have an app that works the following way: 1.the main process is written in C# 2.the main process uses class witten in Managed C++ 3.in classes wirtten in Managed C++, Unmanaged C libs are called 4.as well the main process communicate with other host via .NET remoting The other day a got a socket exception says (this happens at a very low frequency): "An operation was attempted on something that is not a socket" I investegated a lot and come to know this will only happen when the TCP/IP stack is destroyed (IP addresses are all fixed) I don't think TCP/IP stack can be destroyed by codes in C#. In Managed C++, all object reference created on C#'s side were
delete objRefCreatedInCSharp;
in Dispose(). I am told this was done to prevent memory leak. My qusetion is 1. Is delete necessary to prevent memory leak? 2. Won't this delete destroy TCP/IP stack at a certain timing? Thank you very much. -- modified at 0:35 Wednesday 29th March, 2006You only use "delete" when you want to manually mark an object ready for disposal by the GC. If you prematurely use delete, of course, your code will not run properly. Since you did not provide any code examples, it is difficult to determine what your problem is.