Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / October 2007

Tip: Looking for answers? Try searching our database.

Memory allocation and zeroing out...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Atmapuri - 01 Oct 2007 16:41 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.