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. Design and Architecture
  4. Memory management for object growing in size

Memory management for object growing in size

Scheduled Pinned Locked Moved Design and Architecture
performancetutorial
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.
  • D Offline
    D Offline
    Dev S
    wrote on last edited by
    #1

    Hi, Suppose any reference type is stored in some memory location and its data is continuously expanding for example appending string in loop in StringBuilder. How memory manager manages the scenario when its object doesnt has contiguous memory available at that location. It would be great if any one can explain it in detail. Thanks, Devesh

    L B 2 Replies Last reply
    0
    • D Dev S

      Hi, Suppose any reference type is stored in some memory location and its data is continuously expanding for example appending string in loop in StringBuilder. How memory manager manages the scenario when its object doesnt has contiguous memory available at that location. It would be great if any one can explain it in detail. Thanks, Devesh

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      It just gets moved to a block of memory that is large enough to hold the expanded object. This is why you should always try to estimate how big your objects are likely to grow and reserve enough space, to minimise these operations.

      1 Reply Last reply
      0
      • D Dev S

        Hi, Suppose any reference type is stored in some memory location and its data is continuously expanding for example appending string in loop in StringBuilder. How memory manager manages the scenario when its object doesnt has contiguous memory available at that location. It would be great if any one can explain it in detail. Thanks, Devesh

        B Offline
        B Offline
        Bernhard Hiller
        wrote on last edited by
        #3

        Beyond Richard's answer, note that you can run into an OutOfMemoryException when no contiguous block of the desired size is available, i.e. when the memory is fragmented. Also, the desired size is in multiples of 64k.

        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