Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 9th, 2007, 09:02 AM
Authorized User
 
Join Date: Jun 2006
Location: , , .
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??

  #2 (permalink)  
Old January 9th, 2007, 09:55 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
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)
  #3 (permalink)  
Old January 9th, 2007, 03:02 PM
Authorized User
 
Join Date: Jun 2006
Location: , , .
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 ...

  #4 (permalink)  
Old January 10th, 2007, 03:46 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
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)
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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



All times are GMT -4. The time now is 07:39 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.