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. .NET (Core and Framework)
  4. .NET Memory Management

.NET Memory Management

Scheduled Pinned Locked Moved .NET (Core and Framework)
questioncsharpdotnetperformance
3 Posts 3 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.
  • R Offline
    R Offline
    RajeshGuptha
    wrote on last edited by
    #1

    Hi All, I have a doubt on the Out Of Memory Exception thrown by CLR!! Why does it do so, When Windows is providing a virtual memory of 4GB for a 32-bit processor for each and every process!! So according to this if an application starts, then a virtual memory of 4-GB is provided to it, and Windows keeps performing complex algorithms to swap data from RAM to physical memory!!! My doubt is when Windows is doing so much why at all we get an Out of Memory Exception?? I beleive that the memory management is a lot more complex than i have understood, can any of you please enlighten me on the same?? Thanks anyway, Rajesh

    C D 2 Replies Last reply
    0
    • R RajeshGuptha

      Hi All, I have a doubt on the Out Of Memory Exception thrown by CLR!! Why does it do so, When Windows is providing a virtual memory of 4GB for a 32-bit processor for each and every process!! So according to this if an application starts, then a virtual memory of 4-GB is provided to it, and Windows keeps performing complex algorithms to swap data from RAM to physical memory!!! My doubt is when Windows is doing so much why at all we get an Out of Memory Exception?? I beleive that the memory management is a lot more complex than i have understood, can any of you please enlighten me on the same?? Thanks anyway, Rajesh

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      OutOfMemoryExceptions can occur for other reasons, if I remember correctly. For example, GDI resources that don't get cleaned up properly will eventually run out. So, if you create an instance of a class that supports the IDisposable interface then remember to Dispose() it when you are done with it. ColinMackay.net "Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius "If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell

      1 Reply Last reply
      0
      • R RajeshGuptha

        Hi All, I have a doubt on the Out Of Memory Exception thrown by CLR!! Why does it do so, When Windows is providing a virtual memory of 4GB for a 32-bit processor for each and every process!! So according to this if an application starts, then a virtual memory of 4-GB is provided to it, and Windows keeps performing complex algorithms to swap data from RAM to physical memory!!! My doubt is when Windows is doing so much why at all we get an Out of Memory Exception?? I beleive that the memory management is a lot more complex than i have understood, can any of you please enlighten me on the same?? Thanks anyway, Rajesh

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        Colin is correct. If you use any GDI or GDI+ objects, especially when doing you own custom drawing, and don't properly release them by calling Dispose when your done with them, the unmanaged underlying system handles don't get released and are eventually exhausted, causing your OutOfMemory Exception. There are other things that will cause this too, but not properly Disposing the objects you're using, no matter what they are, will result in exhausting one or more of the system handle pools. If you want a quick check of this, open TaskManager, click on its Processes tab, then go to the view menu and pick Select Columns. Turn on Handles, Threads, USER Objects, and GDI Objects. Click OK, then go to the list and file your app. Watch it run for a little while. If any of these counters just keeps rising the longer you use your app, this gives you a hint of where the problem lies. Handle counts usually don't rise above 1,000 in most cases. I have seen examples of piss-poor programming (in commercial software, no less!) where the Handle count grew above 100,000 handles in use! This is a REALLY BIG clue there's leaky code somewhere in that app... RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        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