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. C#
  4. How to free up memory in C# applications?

How to free up memory in C# applications?

Scheduled Pinned Locked Moved C#
questioncsharpxmlperformancetutorial
5 Posts 5 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.
  • N Offline
    N Offline
    Noemi Katinka
    wrote on last edited by
    #1

    Hi everybody, I work with big XML files and i want to free up the memory after a have finished working with one file. If i set the reference of the XmlDocument to null the memory will be free from the GC. But how can i free the memory immediately when i don't need any more the reference? Thanks.

    G C T S 4 Replies Last reply
    0
    • N Noemi Katinka

      Hi everybody, I work with big XML files and i want to free up the memory after a have finished working with one file. If i set the reference of the XmlDocument to null the memory will be free from the GC. But how can i free the memory immediately when i don't need any more the reference? Thanks.

      G Offline
      G Offline
      Gareth H
      wrote on last edited by
      #2

      Noemi Katinka, Call "thing.Dispose()" Regards, Gareth.

      1 Reply Last reply
      0
      • N Noemi Katinka

        Hi everybody, I work with big XML files and i want to free up the memory after a have finished working with one file. If i set the reference of the XmlDocument to null the memory will be free from the GC. But how can i free the memory immediately when i don't need any more the reference? Thanks.

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        how big are these files ? You'd have to force GC, which is usually a bad idea, and can mess up memory management in general in your app. XML files are just text, there's nothing to Dispose.

        Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        1 Reply Last reply
        0
        • N Noemi Katinka

          Hi everybody, I work with big XML files and i want to free up the memory after a have finished working with one file. If i set the reference of the XmlDocument to null the memory will be free from the GC. But how can i free the memory immediately when i don't need any more the reference? Thanks.

          T Offline
          T Offline
          tgrt
          wrote on last edited by
          #4

          Don't mess with it. Let the garbage collector do its job when the memory is needed. You can cause more problems running a garbage collection manually by ending up promoting other objects to higher generations.

          1 Reply Last reply
          0
          • N Noemi Katinka

            Hi everybody, I work with big XML files and i want to free up the memory after a have finished working with one file. If i set the reference of the XmlDocument to null the memory will be free from the GC. But how can i free the memory immediately when i don't need any more the reference? Thanks.

            S Offline
            S Offline
            stano
            wrote on last edited by
            #5

            You could use an XmlReader to parse through the document without having to load the entire document in memory. I've found this useful when loading records from very large XML files (i.e. 100Mb and above).

            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