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
G

GWBas1c

@GWBas1c
About
Posts
11
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Looking for ideas on how to release memory right before a generation 3 garbage collection [modified]
    G GWBas1c

    I ended up using a combination of a queue and access counters. Whenever an object is accessed, I call GC.GetTotalMemory() to determine how many objects to de-reference. Anyway, this thread has nothing to do with Dispose.

    C# visual-studio question csharp dotnet com

  • Looking for ideas on how to release memory right before a generation 3 garbage collection [modified]
    G GWBas1c

    Thanks, but this is for a web server. (I'm also caching more then just text files, but I had to give a simplified example.) The program needs to dynamically adapt to whatever becomes popular without manual tuning from a system administrator. I ended up doing something similar to what was suggested here: http://www.codeproject.com/Messages/3293896/Re-Looking-for-ideas-on-how-to-release-memory-righ.aspx[^]

    C# visual-studio question csharp dotnet com

  • Looking for ideas on how to release memory right before a generation 3 garbage collection [modified]
    G GWBas1c

    That's pretty much what I decided to implement, although I'm experimenting with GC.GetTotalMemory() to determine how many items to pull off of the queue. I keep building the queue until GC.GetTotalMemory() reaches a target size, and if GC.GetTotalMemory() goes above a certain threshold, I remove two or three items. I'm not quite sure how the linked list plays in: I'm keeping references with a dictionary, and the queue is used to increment / decrement an access count. Anyway, thanks!

    C# visual-studio question csharp dotnet com

  • Looking for ideas on how to release memory right before a generation 3 garbage collection [modified]
    G GWBas1c

    Yeah, I agree. The techniques described for .Net 3.0 seem a bit sketchy. I ended up using an algorithm that checks GC.GetTotalMemory() on a periodic basis. As a consequence, the system administrator will have to tune the program to give it a target RAM amount to occupy.

    C# visual-studio question csharp dotnet com

  • Looking for ideas on how to release memory right before a generation 3 garbage collection [modified]
    G GWBas1c

    Look, I appreciate that you're trying to be helpful. My initial question does state the correct problem: I'm trying to release memory right before a generation 3 garbage collection.

    C# visual-studio question csharp dotnet com

  • Looking for ideas on how to release memory right before a generation 3 garbage collection [modified]
    G GWBas1c

    Dispose isn't what I'm looking for. I fully understand the pattern, and it's not appropriate in this situation. I already described why it won't work here: http://www.codeproject.com/Messages/3293314/Re-Looking-for-ideas-on-how-to-release-memory-righ.aspx[^]

    C# visual-studio question csharp dotnet com

  • Looking for ideas on how to release memory right before a generation 3 garbage collection [modified]
    G GWBas1c

    This has nothing to do with Dispose. I'm trying to release references right before a garbage collection occurs. It's for a cache that should grow to occupy as much RAM as possible.

    C# visual-studio question csharp dotnet com

  • Looking for ideas on how to release memory right before a generation 3 garbage collection [modified]
    G GWBas1c

    Like I said, I'm deploying on Mono + Linux, so I can't use COM or CLR-specific APIs.

    C# visual-studio question csharp dotnet com

  • Looking for ideas on how to release memory right before a generation 3 garbage collection [modified]
    G GWBas1c

    No, this has nothing to do with Dispose. So think of it this way: I have 100,000,000,000 large text files on disk. Each time I access a text file, I check to see if it's in RAM. If it is, I just return the pre-loaded string. If it isn't, I load the entire text file into a string and cache the string. Ideally, I'd like to keep all of the text files in RAM as strings, but, as I have 100,000,000,000 of them, I can't keep all of them in RAM. I have no idea when I'm going to access the file again, but it might be as soon as a second, or it might be 10 minutes. The problem is, if I use a dictionary of WeakReferences*, my strings never get beyond generation 0. They get garbage collected too soon, which means that if I access the same file every 2-3 seconds, I have to keep loading it from disk. Thus, I'd like to know when a level 3** garbage collection is going to happen so I can explicitly release my references to the most unused strings and make room in RAM for newer ones. * WeakReference: A weak reference lets you hold a reference to an object without preventing it from being garbage collected. ** Level 3 garbage collection: This is a less frequent garbage collection that only occurs when memory is running low.

    C# visual-studio question csharp dotnet com

  • Is this an acceptable way to make a Control Array? [modified]
    G GWBas1c

    Consider using a List instead of an array, unless you have specific needs that dictate using an Array. The List class will automatically re-size as you add objects, yet you can still iterate and reference by index. For example:

    List controls = new List();

    controls.Add(textbox1);
    controls.Add(textbox2);
    controls.Add(textbox3);

    // ect...

    controls.Add(textbox99999999999);

    for(int i = 0; i < controlArrays.Length; i++)
    {
    if(controls[i] is TextBox)
    (TextBox)controls[i].Text = "Element #" + i.ToString();
    }

    C# data-structures question

  • Looking for ideas on how to release memory right before a generation 3 garbage collection [modified]
    G GWBas1c

    This is a question for GC experts out there: [Please don't respond telling me to use Dispose, it's not what I'm looking for.] I'm currently looking for ideas on how to release memory right before a generation 3 garbage collection. Specifically, I have a bunch of objects that all hold the contents of corresponding files on disk. I'd like to hold as many objects as possible in RAM and only release them as more RAM is needed. The naive approach is to use a Dictionary of WeakReferences. This is what I'm currently doing, but the problem is that some objects never get out of generation 0, and thus are collected and then re-loaded a few seconds later. So are there any ideas with regard to getting a good estimate of when a garbage collection is coming so I can move unused objects into WeakReferences? Some constraints: 1 - My deployment scenario is Mono + Linux, so I can't use the Win32 API, hidden CLR functions, COM, ect, ect. 2 - I'm developing with Visual Studio 2005 Pro. I can't afford VS 2008 Pro, and 2005 has some vital threading features in the debugger that VS 2008 express lacks.

    modified on Friday, December 4, 2009 5:32 AM

    C# visual-studio question csharp dotnet com
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups