Hi!
It seems that every memory allocated by the garbagge collector
is zeroed out (an array is set to all zeros).
Is there any way to allocate memory via garabage
collector without having that automatic zero out feature?
In my case that zero out is adding a serious performance penalty.
Thanks!
Atmapuri
Willy Denoyette [MVP] - 01 Oct 2007 16:56 GMT
> Hi!
>
> It seems that every memory allocated by the garbagge collector
> is zeroed out (an array is set to all zeros).
Memory used to store object instances is zeroed out by GC after a
compactation run, as such the actual object creation does not have to do it.
> Is there any way to allocate memory via garabage
> collector without having that automatic zero out feature?
No there is not, which is a great thing, you don't wan your instances to
contain garbage do you?
> In my case that zero out is adding a serious performance penalty.
What makes you think that?
Willy.
Ignacio Machin ( .NET/ C# MVP ) - 01 Oct 2007 18:53 GMT
Hi,
> Hi!
>
[quoted text clipped - 3 lines]
> Is there any way to allocate memory via garabage
> collector without having that automatic zero out feature?
This has no sense, what will happen then when you create a new instance? You
will have garbage.
> In my case that zero out is adding a serious performance penalty.
I can assure you that your problem resides somewhere else.
Post back with more details and code and let's see what is going on.
Ben Voigt [C++ MVP] - 03 Oct 2007 18:33 GMT
> Hi!
>
[quoted text clipped - 5 lines]
>
> In my case that zero out is adding a serious performance penalty.
Then reuse the object, instead of letting it be collected. If you are
allocating memory too fast you will have performance problems due to running
the GC too often, and the zeroing cost is a very small part of the price you
pay.
> Thanks!
> Atmapuri