Memory allocation and zeroing out...

A

Atmapuri

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
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Atmapuri said:
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?

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.
 
B

Ben Voigt [C++ MVP]

Atmapuri said:
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.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top