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. Garbage Collection and small objects

Garbage Collection and small objects

Scheduled Pinned Locked Moved C#
performancecsharpcssdatabasesqlite
1 Posts 1 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.
  • Richard Andrew x64R Offline
    Richard Andrew x64R Offline
    Richard Andrew x64
    wrote on last edited by
    #1

    My program loads objects that are approximately 100 bytes in size from a SQLite database. It loads about 4 million of them and the resulting process memory usage grows to around 1 GB. I'm looking to speed this up greatly, because right now it takes 40 seconds to load all the objects. In the Visual Studio debugging tools memory usage window, it shows that garbage collections are occurring five or six times per second during this loading process. So I started looking into ways to suppress the garbage collector, thinking that that could make a difference. I found the function

    public static bool TryStartNoGCRegion (long totalSize);

    Supposedly this allows you to allocate a large segment of memory up front and cause the GC to be less aggressive. So I calculate the size I need by multiplying 100 bytes times 4 million objects, or around 400 MB. But when I call the function with 400 million as the requested size, it fails with an ArgumentOutOfRange exception. Is it unrealistic to think I can allocate that much in one go, or there something else wrong? Does anyone know how to use this function? (Machine has 64 GB of RAM.)

    The difficult we do right away... ...the impossible takes slightly longer.

    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