Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. About delete in Managed C++

About delete in Managed C++

Scheduled Pinned Locked Moved Managed C++/CLI
csharpc++data-structuresperformancequestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bob_Sun
    wrote on last edited by
    #1

    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

    G 1 Reply Last reply
    0
    • B Bob_Sun

      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

      G Offline
      G Offline
      George L Jackson
      wrote on last edited by
      #2

      You 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.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups