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. Is delete useful ?

Is delete useful ?

Scheduled Pinned Locked Moved Managed C++/CLI
dotnetquestion
3 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.
  • A Offline
    A Offline
    aljodav
    wrote on last edited by
    #1

    In a very long loop (up to 500.000), I have a String^ variable that takes long lengths (and different values) each loop cycle. I wonder if it's worthy to delete the variable at each loop cycle's end; if delete is not used, will the CLR take care of it ?

    N 1 Reply Last reply
    0
    • A aljodav

      In a very long loop (up to 500.000), I have a String^ variable that takes long lengths (and different values) each loop cycle. I wonder if it's worthy to delete the variable at each loop cycle's end; if delete is not used, will the CLR take care of it ?

      N Offline
      N Offline
      Nish Nishant
      wrote on last edited by
      #2

      String is not IDisposable, so there's no point in calling delete. For another thing, you don't need to do that anyway, the GC will appropriately come into play as and when required.

      Regards, Nish


      Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
      C++/CLI in Action (*E-Book is out, Print version April 6th*)

      Fly on your way like an eagle Fly as high as the sun On your wings like an eagle Fly and touch the sun

      A 1 Reply Last reply
      0
      • N Nish Nishant

        String is not IDisposable, so there's no point in calling delete. For another thing, you don't need to do that anyway, the GC will appropriately come into play as and when required.

        Regards, Nish


        Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
        C++/CLI in Action (*E-Book is out, Print version April 6th*)

        Fly on your way like an eagle Fly as high as the sun On your wings like an eagle Fly and touch the sun

        A Offline
        A Offline
        aljodav
        wrote on last edited by
        #3

        Thanks Nish. :cool:

        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