Re: GC with lots of small ones

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: AlexS (salexru2000NO_at_SPAMsympaticoPLEASE.ca)
Date: 05/27/04


Date: Thu, 27 May 2004 19:52:55 -0400

Thanks, Chris

I just want to confirm that you confirmed my findings. As most of strings
and other objects are members in long existing containers most of my points
seems to be in line with what you said. I wonder if next version of FW will
be better in this respect. Note, this is heavy duty processing - I have
hundreds of 000's of objects created and existing during app lifetime.

Now I have much cleaner picture and better behaving app. I am sad only
because now I have to find out how to make clr profiler to behave in more
correct fashion.
It eats too much memory - log files exceeding 100MB
It crashes on exceptions or says not enough disk space - while there is
plenty - to display some graph all too frequently
It doesn't allow to filter out namespaces, objects and calls

Anyway, I managed to make the app more less eating heap. That's already a
progress.

Rgds
Alex

""Chris Lyon [MSFT]"" <clyon@online.microsoft.com> wrote in message
news:NlBP%236AREHA.2968@cpmsftngxa10.phx.gbl...
> Hi Alex
>
> >So, if to sum up
> >- if string creation and processing before releasing reference take some
> >time bigger than GC0 and GC1, they could be lost in heap
>
> True. If your object survives a generation 0 collection, then dies,
you've got "mid-life crisis", and that object (in your case a string) will
be in memory much longer than you need
> it.
>
> >- if big string is replaced by another big string, like str=<big string>;
> ><process>; str=<another big string> better to use str=null or
> >str=String.Empty before next assignment
>
> By changing the reference from the first string, you've abandoned it in
memory and the GC will take care of it. So nulling won't help, but won't
hurt either.
>
> >- if objects could exist for long time, they should be nulled explicitly
>
> Only if they are member variables, and the container object is still
alive.
>
> >- if object implements IDispose it must be disposed before next assigment
> >explicitly
>
> That's generally good practice. Consider using the C# using pattern where
appropriate.
>
> >- when objects are passed between threads or asynch methods - null them
> >explicitly
> >- when objects are passed between recursive calls - null them explicitly
>
> Nulling them won't help them get collected any faster unless they are
members.
>

PS:
By the way, I found stringbuilder helps with small ones too. What is big - 8
chars or 80?



Relevant Pages

  • Re: weird problem
    ... Obviously plus a few missing members like prev, ... 'tmp' has for a relation to it - 'tmp' could point to an element ... it fails to obtain as much memory as requested. ... print out a human-readable string for what errno is set to. ...
    (comp.lang.c)
  • Re: using structs like BROWSEINFO and OPENFILENAME (string members)
    ... Private Type BROWSEINFO ... pszDisplayName As String ... > ...notice the data type change for the two string members. ... > memory at lpTitle and the data is ansi, so somehow vb figured out to use ...
    (microsoft.public.vb.winapi)
  • Transition to C++ from C, by programing strings!
    ... // introduces special operator for suffix compares ... advantage of containers, iterators, and pointers, to right tight ... inline string _reverseconst ... start building them on the free store, which can spill out into memory ...
    (comp.unix.programmer)
  • Learn to program strings in C++ by example.
    ... // introduces special operator for suffix compares ... advantage of containers, iterators, and pointers, to right tight ... inline string _reverseconst ... start building them on the free store, which can spill out into memory ...
    (comp.sys.mac.system)
  • Learn to program strings in C++ by example!
    ... // introduces special operator for suffix compares ... advantage of containers, iterators, and pointers, to right tight ... inline string _reverseconst ... start building them on the free store, which can spill out into memory ...
    (comp.sys.mac.programmer.help)