Click here to Skip to main content
15,890,399 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# and timer Pin
The Man from U.N.C.L.E.3-Dec-09 22:14
The Man from U.N.C.L.E.3-Dec-09 22:14 
GeneralRe: C# and timer Pin
Corinna John3-Dec-09 22:18
Corinna John3-Dec-09 22:18 
GeneralRe: C# and timer Pin
PIEBALDconsult4-Dec-09 4:02
mvePIEBALDconsult4-Dec-09 4:02 
GeneralRe: C# and timer Pin
nsjn4-Dec-09 18:56
nsjn4-Dec-09 18:56 
GeneralRe: C# and timer Pin
nsjn4-Dec-09 21:22
nsjn4-Dec-09 21:22 
QuestionLooking for ideas on how to release memory right before a generation 3 garbage collection [modified] Pin
GWBas1c3-Dec-09 19:23
GWBas1c3-Dec-09 19:23 
AnswerRe: Looking for ideas on how to release memory right before a generation 3 garbage collection Pin
Abhinav S3-Dec-09 19:58
Abhinav S3-Dec-09 19:58 
GeneralRe: Looking for ideas on how to release memory right before a generation 3 garbage collection Pin
GWBas1c3-Dec-09 20:28
GWBas1c3-Dec-09 20:28 
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.
AnswerRe: Looking for ideas on how to release memory right before a generation 3 garbage collection Pin
Martin#3-Dec-09 20:38
Martin#3-Dec-09 20:38 
GeneralRe: Looking for ideas on how to release memory right before a generation 3 garbage collection Pin
GWBas1c3-Dec-09 21:01
GWBas1c3-Dec-09 21:01 
GeneralRe: Looking for ideas on how to release memory right before a generation 3 garbage collection Pin
Martin#3-Dec-09 21:20
Martin#3-Dec-09 21:20 
AnswerRe: Looking for ideas on how to release memory right before a generation 3 garbage collection Pin
puri keemti3-Dec-09 22:17
puri keemti3-Dec-09 22:17 
GeneralRe: Looking for ideas on how to release memory right before a generation 3 garbage collection Pin
GWBas1c3-Dec-09 23:32
GWBas1c3-Dec-09 23:32 
GeneralRe: Looking for ideas on how to release memory right before a generation 3 garbage collection Pin
puri keemti3-Dec-09 23:35
puri keemti3-Dec-09 23:35 
GeneralRe: Looking for ideas on how to release memory right before a generation 3 garbage collection Pin
GWBas1c3-Dec-09 23:41
GWBas1c3-Dec-09 23:41 
GeneralRe: Looking for ideas on how to release memory right before a generation 3 garbage collection Pin
puri keemti3-Dec-09 23:50
puri keemti3-Dec-09 23:50 
RantRe: Looking for ideas on how to release memory right before a generation 3 garbage collection Pin
GWBas1c4-Dec-09 0:09
GWBas1c4-Dec-09 0:09 
GeneralRe: Looking for ideas on how to release memory right before a generation 3 garbage collection Pin
Shameel4-Dec-09 0:12
professionalShameel4-Dec-09 0:12 
AnswerRe: Looking for ideas on how to release memory right before a generation 3 garbage collection Pin
Dave Kreskowiak4-Dec-09 3:45
mveDave Kreskowiak4-Dec-09 3:45 
GeneralRe: Looking for ideas on how to release memory right before a generation 3 garbage collection Pin
GWBas1c4-Dec-09 4:02
GWBas1c4-Dec-09 4:02 
AnswerRe: Looking for ideas on how to release memory right before a generation 3 garbage collection Pin
Alan Balkany4-Dec-09 4:15
Alan Balkany4-Dec-09 4:15 
GeneralRe: Looking for ideas on how to release memory right before a generation 3 garbage collection Pin
GWBas1c4-Dec-09 10:43
GWBas1c4-Dec-09 10:43 
AnswerRe: Looking for ideas on how to release memory right before a generation 3 garbage collection Pin
Gideon Engelberth4-Dec-09 4:30
Gideon Engelberth4-Dec-09 4:30 
GeneralRe: Looking for ideas on how to release memory right before a generation 3 garbage collection Pin
GWBas1c4-Dec-09 10:50
GWBas1c4-Dec-09 10:50 
AnswerRe: Looking for ideas on how to release memory right before a generation 3 garbage collection Pin
Natza Mitzi6-Dec-09 10:18
Natza Mitzi6-Dec-09 10:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.