Wrox Programmer Forums
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 9th, 2007, 10:02 AM
Authorized User
 
Join Date: Jun 2006
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Memory

Hi,i have a C# class that act as a buffer and it holds a large data,
so am looking for a way to directly remove the class instance
from the memory without waiting the garbage collector and even
without the "using block" that is used for critical code cuz
in my case i cannot assemble the code in one block, even i read
that it is not recommended to use "Dispose" method.

any idea??

 
Old January 9th, 2007, 10:55 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Please don't post to two forums.
I think this is a poor approach, do you have any reason to believe the garbage collector will not do its job?
Unless you are suffering problems I would try to live with the system, trying to second guess often leads to more problems than it solves.

--

Joe (Microsoft MVP - XML)
 
Old January 9th, 2007, 04:02 PM
Authorized User
 
Join Date: Jun 2006
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The reason is that am handling critical real time application that reserves a large memory, and the following are other reasons:
1- Wrox/Beginning C#/Chapter 1/Garbage Collection:
Last article says:
"There are some implications for PROGRAMMERS here, Since this work is done for you at an unpredictable time, applications have to be designed with this in mind.
Code that requires a lot of memory to run should tidy itself up rather than waiting for garbage collection to happen, but this isn't anything like as tricky as it sounds."

2- Wrox/Professional C# 2nd Edition/Chapter 1/Garbage Collection:
Last article says:
"One aspect of garbage collection that it is important to be aware
of is that not deterministic. In other words, you cannot guarantee
when the garbage collector will be called; it will be called when
the CLR decides that it is needed (unless you explicitly call the
collector)."

God blesses ...

 
Old January 10th, 2007, 04:46 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well I slightly disagree with the first quote when it says it's not as tricky as it sounds.
You can call the garbage collector yourself but every Microsoft article I've read advises against it. If you implement IDisposable on your class let the CLR worry about tidy up. The garbage collection heuristic is getting better and better. If you feel your app is being affected by by inefficient collection then I'd post the code here where I will make sure it's passed to Microsoft for examination.

--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Memory akkad C# 0 January 9th, 2007 10:01 AM
Out of Memory ocabrera70 Classic ASP Components 0 February 15th, 2006 09:08 PM
Out of memory : simplyAns All Other Wrox Books 0 November 9th, 2004 08:56 AM
Memory problem…. m.harte SQL Server 2000 1 November 8th, 2004 04:47 AM
Memory linguva Access 2 December 19th, 2003 07:22 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.