Re: Memory usage

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Daniel Moth (dmoth74_at_hotmail.com)
Date: 03/03/05


Date: Thu, 3 Mar 2005 21:13:47 -0000

Please see my reply in your other post. In short, the "no heap allocations"
comment applies to the second approach where there are no static variables.

Cheers
Daniel

--
http://www.danielmoth.com/Blog/
"maark" <maark@discussions.microsoft.com> wrote in message 
news:0F4ED004-89E6-4D8A-B6BB-412844355756@microsoft.com...
> If static variables are not allocated on the heap in .NET CF  - where are
> they stored.
>
> "Daniel Moth" wrote:
>
>> That is my understanding too. It basically creates a new Color object 
>> which
>> since it is a valuetype is simply assigning some variables (based on a 
>> bunch
>> of conditions, some shifting etc) so there is no heap allocations.
>>
>> That doesn't change the recommendation to go with the first approach 
>> though
>> does it?
>>
>> Cheers
>> Daniel
>> --
>> http://www.danielmoth.com/Blog/
>>
>>
>> "Alex Feinman [MVP]" <public_news@alexfeinman.com> wrote in message
>> news:ORbt4DCIFHA.3196@TK2MSFTNGP15.phx.gbl...
>> > But color is a value type...
>> > Woudn't the only difference be in a few lines of IL that stuff the RGB
>> > values in the Color fields?
>> >
>> > -- 
>> > Alex Feinman
>> > ---
>> > Visit http://www.opennetcf.org
>> > "Daniel Moth" <dmoth74@hotmail.com> wrote in message
>> > news:OFOHkiBIFHA.3444@TK2MSFTNGP10.phx.gbl...
>> >> Those two are different.
>> >>
>> >> The first one creates a color and returns *it* everytime you ask.
>> >> The second creates a new color *every* time you ask
>> >>
>> >> Go with the first one.
>> >>
>> >> Cheers
>> >> Daniel
>> >> --
>> >> http://www.danielmoth.com/Blog/
>> >>
>> >>
>> >> "maark" <maark@discussions.microsoft.com> wrote in message
>> >> news:E99A8856-BF0A-47EC-9867-CD921EE2FB9D@microsoft.com...
>> >>> Platform: WinCE 4.2, C#
>> >>>
>> >>> Newbie question:
>> >>> Is there any difference in memory footprint between the 2 following
>> >>> declarations:
>> >>>
>> >>>     public static Color FG_COLOR = Color.FromArgb(100,100,30);
>> >>>
>> >>>     public static Color FgColor
>> >>>      {
>> >>>            get {return Color.FromArgb(100,100,30);}
>> >>>      }
>> >>>
>> >>> TIA,
>> >>>
>> >>> Mark
>> >>>
>> >>>
>> >>
>> >
>>
>>