Tech Off Thread

1 post

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

WeakReference and the workstation GC

Back to Forum: Tech Off
  • User profile image
    Sk4rlath

    I'm writing an application that stores image (bitmap) data in a SQL Server instance.  No problems there, everything works great.  In order to save on memory and bandwidth, I decided to implement a client-side cache system using WeakReferences.  Essentially, whenever an image is requested I check to see if there's a WeakReference to it in the cache and that the reference is still alive.  If it is, then I just return it.  If not, I hit the database and cache the result.

    The problem lies in the fact that this does me absolutely no good.  On workstations the GC runs concurrently and garbage collects 'all the time'.  I ran my app and watched performance counters and saw it GC immediately after I set the WeakReference.

    So - WeakReferences are mostly useless on Workstation GCs?

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.